mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-13 05:31:37 +08:00
scan frequency as proposed by serratus
This commit is contained in:
+18
-10
@@ -296,16 +296,29 @@ function update() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function start() {
|
function startContinuousUpdate() {
|
||||||
|
var next = null,
|
||||||
|
delay = 1000 / (_config.frequency || 60);
|
||||||
|
|
||||||
_stopped = false;
|
_stopped = false;
|
||||||
( function frame() {
|
(function frame(timestamp) {
|
||||||
|
next = next || timestamp;
|
||||||
if (!_stopped) {
|
if (!_stopped) {
|
||||||
|
if (timestamp >= next) {
|
||||||
|
next += delay;
|
||||||
update();
|
update();
|
||||||
if (_onUIThread && _config.inputStream.type === "LiveStream") {
|
}
|
||||||
window.requestAnimFrame(frame);
|
window.requestAnimFrame(frame);
|
||||||
}
|
}
|
||||||
|
}(performance.now()));
|
||||||
|
}
|
||||||
|
|
||||||
|
function start() {
|
||||||
|
if (_onUIThread && _config.inputStream.type === "LiveStream") {
|
||||||
|
startContinuousUpdate();
|
||||||
|
} else {
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
}());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initWorker(cb) {
|
function initWorker(cb) {
|
||||||
@@ -360,7 +373,6 @@ function workerInterface(factory) {
|
|||||||
var imageWrapper;
|
var imageWrapper;
|
||||||
|
|
||||||
self.onmessage = function(e) {
|
self.onmessage = function(e) {
|
||||||
setTimeout(function() {
|
|
||||||
if (e.data.cmd === 'init') {
|
if (e.data.cmd === 'init') {
|
||||||
var config = e.data.config;
|
var config = e.data.config;
|
||||||
config.numOfWorkers = 0;
|
config.numOfWorkers = 0;
|
||||||
@@ -376,7 +388,6 @@ function workerInterface(factory) {
|
|||||||
} else if (e.data.cmd === 'setReaders') {
|
} else if (e.data.cmd === 'setReaders') {
|
||||||
Quagga.setReaders(e.data.readers);
|
Quagga.setReaders(e.data.readers);
|
||||||
}
|
}
|
||||||
}, Quagga.getConfig().scanDelay || 0);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function onProcessed(result) {
|
function onProcessed(result) {
|
||||||
@@ -518,8 +529,5 @@ export default {
|
|||||||
},
|
},
|
||||||
ImageWrapper: ImageWrapper,
|
ImageWrapper: ImageWrapper,
|
||||||
ImageDebug: ImageDebug,
|
ImageDebug: ImageDebug,
|
||||||
ResultCollector: ResultCollector,
|
ResultCollector: ResultCollector
|
||||||
getConfig: function getConfig() {
|
|
||||||
return _config;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user