mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-16 05:10:00 +01:00
Added DecodeQr Module, Test
This commit is contained in:
2968
dist/image-sequencer.js
vendored
2968
dist/image-sequencer.js
vendored
File diff suppressed because one or more lines are too long
1
examples/IS-QR.js
Normal file
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
BIN
examples/IS-QR.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
@@ -23,6 +23,7 @@
|
||||
"bootstrap": "~3.2.0",
|
||||
"font-awesome": "~4.5.0",
|
||||
"jquery": "~2",
|
||||
"jsqr": "^0.2.2",
|
||||
"urify": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -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')
|
||||
}
|
||||
|
||||
29
src/modules/DecodeQr/Module.js
Normal file
29
src/modules/DecodeQr/Module.js
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user