mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-13 11:50:02 +01:00
Added DecodeQr Module, Test
This commit is contained in:
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user