Skip to content

Commit

Permalink
new config variable scanDelay to add some time between two scans
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Jauernig committed Mar 22, 2016
1 parent 82ef5b9 commit 9b1e697
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/quagga.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,21 +360,23 @@ function workerInterface(factory) {
var imageWrapper;

self.onmessage = function(e) {
if (e.data.cmd === 'init') {
var config = e.data.config;
config.numOfWorkers = 0;
imageWrapper = new Quagga.ImageWrapper({
x: e.data.size.x,
y: e.data.size.y
}, new Uint8Array(e.data.imageData));
Quagga.init(config, ready, imageWrapper);
Quagga.onProcessed(onProcessed);
} else if (e.data.cmd === 'process') {
imageWrapper.data = new Uint8Array(e.data.imageData);
Quagga.start();
} else if (e.data.cmd === 'setReaders') {
Quagga.setReaders(e.data.readers);
}
setTimeout(function() {
if (e.data.cmd === 'init') {
var config = e.data.config;
config.numOfWorkers = 0;
imageWrapper = new Quagga.ImageWrapper({
x: e.data.size.x,
y: e.data.size.y
}, new Uint8Array(e.data.imageData));
Quagga.init(config, ready, imageWrapper);
Quagga.onProcessed(onProcessed);
} else if (e.data.cmd === 'process') {
imageWrapper.data = new Uint8Array(e.data.imageData);
Quagga.start();
} else if (e.data.cmd === 'setReaders') {
Quagga.setReaders(e.data.readers);
}
}, Quagga.getConfig().scanDelay || 0);
};

function onProcessed(result) {
Expand Down Expand Up @@ -516,5 +518,8 @@ export default {
},
ImageWrapper: ImageWrapper,
ImageDebug: ImageDebug,
ResultCollector: ResultCollector
ResultCollector: ResultCollector,
getConfig: function getConfig() {
return _config;
}
};

0 comments on commit 9b1e697

Please sign in to comment.