Making patch-size configurable; Added Image-Dimensions constraint

pull/35/head
Christoph Oberhofer 10 years ago
parent 74e2c8d447
commit 178b5b0a4b

@ -40,8 +40,8 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
} }
_patchSize = { _patchSize = {
x : 16 * ( _config.halfSample ? 1 : 2), x : _config.patchSize * ( _config.halfSample ? 0.5 : 1),
y : 16 * ( _config.halfSample ? 1 : 2) y : _config.patchSize * ( _config.halfSample ? 0.5 : 1)
}; };
_numPatches.x = _currentImageWrapper.size.x / _patchSize.x | 0; _numPatches.x = _currentImageWrapper.size.x / _patchSize.x | 0;

@ -31,6 +31,7 @@ define(function(){
}, },
locator: { locator: {
halfSample: true, halfSample: true,
patchSize: 32,
showCanvas: false, showCanvas: false,
showPatches: false, showPatches: false,
showFoundPatches: false, showFoundPatches: false,

@ -82,7 +82,24 @@ function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, Ba
_inputStream.addEventListener("canrecord", canRecord.bind(undefined, cb)); _inputStream.addEventListener("canrecord", canRecord.bind(undefined, cb));
} }
function checkImageConstraints() {
var patchSize,
width = _inputStream.getWidth(),
height = _inputStream.getHeight();
if (_config.locate) {
patchSize = _config.locator.patchSize * ( _config.locator.halfSample ? 0.5 : 1);
if ((width % patchSize) === 0 && (height % patchSize) === 0) {
return true;
}
}
throw new Error("Image dimensions do not comply with the current settings: Width (" +
width + " )and height (" + height +
") must a multiple of " + patchSize);
}
function canRecord(cb) { function canRecord(cb) {
checkImageConstraints();
initCanvas(); initCanvas();
_framegrabber = FrameGrabber.create(_inputStream, _canvasContainer.dom.image); _framegrabber = FrameGrabber.create(_inputStream, _canvasContainer.dom.image);
initConfig(); initConfig();
@ -384,6 +401,10 @@ function(Code128Reader, EANReader, InputStream, ImageWrapper, BarcodeLocator, Ba
size: 800 size: 800
}; };
config.numOfWorkers = 1; config.numOfWorkers = 1;
config.locator = {
halfSample: false,
patchSize: 25
};
this.init(config, function() { this.init(config, function() {
Events.once("detected", function(result) { Events.once("detected", function(result) {
_stopped = true; _stopped = true;

Loading…
Cancel
Save