Added DecodeQr Module, Test

This commit is contained in:
Chinmay Pandhare
2017-07-23 12:50:22 +05:30
parent 557a1166b3
commit 78beae48d9
7 changed files with 2908 additions and 106 deletions

2968
dist/image-sequencer.js vendored

File diff suppressed because one or more lines are too long

1
examples/IS-QR.js Normal file

File diff suppressed because one or more lines are too long

BIN
examples/IS-QR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -23,6 +23,7 @@
"bootstrap": "~3.2.0",
"font-awesome": "~4.5.0",
"jquery": "~2",
"jsqr": "^0.2.2",
"urify": "^2.1.0"
},
"devDependencies": {

View File

@@ -8,5 +8,6 @@ module.exports = {
'do-nothing-pix': require('./modules/DoNothingPix/Module.js'),
'invert': require('./modules/Invert/Module'),
'crop': require('./modules/Crop/Module'),
'segmented-colormap': require('./modules/SegmentedColormap/Module')
'segmented-colormap': require('./modules/SegmentedColormap/Module'),
'decode-qr': require('./modules/DecodeQr/Module')
}

View File

@@ -0,0 +1,29 @@
/*
* Decodes QR from a given image.
*/
module.exports = function DoNothing(options) {
options = options || {};
options.title = "Decode QR Code";
var output;
var jsQR = require('jsqr');
var getPixels = require('get-pixels');
function draw(input,callback) {
var this_ = this;
getPixels(input.src,function(err,pixels){
if(err) throw err;
var w = pixels.shape[0];
var h = pixels.shape[1];
var decoded = jsQR.decodeQRFromImage(pixels.data,w,h);
this_.output = input;
this_.output.data = decoded;
callback();
});
}
return {
options: options,
draw: draw,
output: output
}
}

View File

@@ -9,6 +9,7 @@ require('../src/ImageSequencer.js');
var sequencer = ImageSequencer({ ui: "none" });
var image = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z";
var qr = require('../examples/IS-QR.js');
sequencer.loadImages(image);
sequencer.addSteps(['do-nothing-pix','invert','invert']);
@@ -23,3 +24,14 @@ test("Twice inverted image is identical to original image", function (t) {
t.equal(sequencer.images.image1.steps[1].output.src, sequencer.images.image1.steps[3].output.src);
t.end();
});
test("Decode QR module works properly :: setup", function (t) {
sequencer.loadImage(qr).addSteps('decode-qr').run(function(){
t.end();
});
});
test("Decode QR module works properly :: teardown", function (t) {
t.equal("http://github.com/publiclab/image-sequencer",sequencer.images.image2.steps[1].output.data);
t.end();
});