pull/98/merge
Matthias Jauernig 9 years ago
commit 1bd33b2eea

@ -698,32 +698,32 @@ CVUtils.calculatePatchSize = function(patchSize, imgSize) {
CVUtils._parseCSSDimensionValues = function(value) { CVUtils._parseCSSDimensionValues = function(value) {
var dimension = { var dimension = {
value: parseFloat(value), value: parseFloat(value),
unit: value.indexOf("%") === value.length - 1 ? "%" : "%" unit: value.indexOf("%") === value.length - 1 ? "%" : "px"
}; };
return dimension; return dimension;
}; };
CVUtils._dimensionsConverters = { CVUtils._dimensionsConverters = {
top: function(dimension, context) { top: function top(dimension, context) {
if (dimension.unit === "%") { return Math.floor((dimension.unit === "%")
return Math.floor(context.height * (dimension.value / 100)); ? (context.height * (dimension.value / 100))
} : dimension.value);
}, },
right: function(dimension, context) { right: function right(dimension, context) {
if (dimension.unit === "%") { return Math.floor((dimension.unit === "%")
return Math.floor(context.width - (context.width * (dimension.value / 100))); ? (context.width - context.width * (dimension.value / 100))
} : (context.width - dimension.value));
}, },
bottom: function(dimension, context) { bottom: function bottom(dimension, context) {
if (dimension.unit === "%") { return Math.floor((dimension.unit === "%")
return Math.floor(context.height - (context.height * (dimension.value / 100))); ? (context.height - context.height * (dimension.value / 100))
} : (context.height - dimension.value));
}, },
left: function(dimension, context) { left: function left(dimension, context) {
if (dimension.unit === "%") { return Math.floor((dimension.unit === "%")
return Math.floor(context.width * (dimension.value / 100)); ? (context.width * (dimension.value / 100))
} : dimension.value);
} }
}; };

@ -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) {

Loading…
Cancel
Save