mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-12 21:21:42 +08:00
@@ -23,7 +23,9 @@
|
||||
"destructuring": true,
|
||||
"objectLiteralComputedProperties": true
|
||||
},
|
||||
"globals": {},
|
||||
"globals": {
|
||||
"ENV": true
|
||||
},
|
||||
"rules": {
|
||||
"no-unused-expressions": 1,
|
||||
"no-extra-boolean-cast": 1,
|
||||
|
||||
@@ -104,6 +104,12 @@ file is only valid for the non-uglified version `quagga.js` because the
|
||||
minified version is altered after compression and does not align with the map
|
||||
file any more.
|
||||
|
||||
### Node
|
||||
|
||||
The code in the `dist` folder is only targeted to the browser and won't work in
|
||||
node due to the dependency on the DOM. For the use in node, the `build` command
|
||||
also creates a `quagga.js` file in the `lib` folder.
|
||||
|
||||
## <a name="api">API</a>
|
||||
|
||||
You can check out the [examples][github_examples] to get an idea of how to
|
||||
@@ -545,6 +551,13 @@ on the ``singleChannel`` flag in the configuration when using ``decodeSingle``.
|
||||
|
||||
## <a name="changelog">Changelog</a>
|
||||
|
||||
### 2016-02-18
|
||||
|
||||
- Internal Changes
|
||||
- Restructuring into meaningful folders
|
||||
- Removing debug-code in production build
|
||||
|
||||
|
||||
### 2016-02-15
|
||||
Take a look at the release-notes ([0.9.0]
|
||||
(https://github.com/serratus/quaggaJS/releases/tag/v0.9.0))
|
||||
|
||||
Vendored
+371
-320
File diff suppressed because one or more lines are too long
Vendored
+3
-3
File diff suppressed because one or more lines are too long
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
production: false,
|
||||
development: true,
|
||||
node: false
|
||||
};
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
production: true,
|
||||
development: false,
|
||||
node: true
|
||||
};
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
production: true,
|
||||
development: false,
|
||||
node: false
|
||||
};
|
||||
@@ -95,7 +95,6 @@ $(function() {
|
||||
patchSize: "large",
|
||||
halfSample: false
|
||||
},
|
||||
numOfWorkers: 1,
|
||||
decoder: {
|
||||
readers: ["code_128_reader"]
|
||||
},
|
||||
@@ -103,7 +102,7 @@ $(function() {
|
||||
src: null
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
App.init();
|
||||
|
||||
function calculateRectFromArea(canvas, area) {
|
||||
@@ -168,4 +167,4 @@ $(function() {
|
||||
$node.find("h4.code").html(code);
|
||||
$("#result_strip ul.thumbnails").prepend($node);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var path = require('path');
|
||||
var webpack = require('webpack');
|
||||
|
||||
module.exports = function(config) {
|
||||
config.set({
|
||||
@@ -25,12 +26,18 @@ module.exports = function(config) {
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['', '.js', '.jsx'],
|
||||
alias: {
|
||||
'input_stream$': path.resolve(__dirname, 'src/input_stream'),
|
||||
'frame_grabber$': path.resolve(__dirname, 'src/frame_grabber')
|
||||
}
|
||||
}
|
||||
extensions: ['', '.js', '.jsx'],
|
||||
root: path.resolve(__dirname),
|
||||
alias: {
|
||||
'input_stream$': 'src/input/input_stream',
|
||||
'frame_grabber$': 'src/input/frame_grabber'
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
ENV: require(path.join(__dirname, './env/production'))
|
||||
})
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
'karma-chrome-launcher',
|
||||
|
||||
+3
-2
@@ -33,9 +33,10 @@ module.exports = function(config) {
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['', '.js', '.jsx'],
|
||||
root: path.resolve(__dirname),
|
||||
alias: {
|
||||
'input_stream$': path.resolve(__dirname, 'src/input_stream'),
|
||||
'frame_grabber$': path.resolve(__dirname, 'src/frame_grabber')
|
||||
'input_stream$': 'src/input/input_stream',
|
||||
'frame_grabber$': 'src/input/frame_grabber'
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const CVUtils = require('../src/cv_utils'),
|
||||
const CVUtils = require('../src/common/cv_utils'),
|
||||
Ndarray = require("ndarray"),
|
||||
Interp2D = require("ndarray-linear-interpolate").d2;
|
||||
|
||||
|
||||
+332
-311
File diff suppressed because one or more lines are too long
+6
-2
@@ -11,6 +11,7 @@
|
||||
"babel-loader": "^5.3.2",
|
||||
"chai": "^3.4.1",
|
||||
"core-js": "^1.2.1",
|
||||
"cross-env": "^1.0.7",
|
||||
"eslint": "^1.10.3",
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-cli": "^0.1.13",
|
||||
@@ -39,8 +40,11 @@
|
||||
"scripts": {
|
||||
"test": "grunt test",
|
||||
"integrationtest": "grunt integrationtest",
|
||||
"build": "webpack && webpack --config webpack.config.min.js && grunt uglyasm && webpack --config webpack.node.config.js",
|
||||
"watch": "webpack --watch",
|
||||
"build:dev": "cross-env BUILD_ENV=development webpack",
|
||||
"build:prod": "cross-env BUILD_ENV=production webpack --config webpack.config.min.js && grunt uglyasm",
|
||||
"build:node": "cross-env BUILD_ENV=node webpack --config webpack.node.config.js",
|
||||
"build": "npm run build:dev && npm run build:prod && npm run build:node",
|
||||
"watch": "cross-env BUILD_ENV=development webpack --watch",
|
||||
"lint": "eslint src"
|
||||
},
|
||||
"repository": {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import ImageDebug from './image_debug';
|
||||
import ImageDebug from '../common/image_debug';
|
||||
|
||||
function contains(codeResult, list) {
|
||||
if (list) {
|
||||
@@ -1,6 +1,6 @@
|
||||
import SubImage from './subImage';
|
||||
import CVUtils from './cv_utils';
|
||||
import ArrayHelper from './array_helper';
|
||||
import CVUtils from '../common/cv_utils';
|
||||
import ArrayHelper from '../common/array_helper';
|
||||
import {vec2} from 'gl-matrix';
|
||||
|
||||
/**
|
||||
@@ -0,0 +1,51 @@
|
||||
module.exports = {
|
||||
inputStream: {
|
||||
name: "Live",
|
||||
type: "LiveStream",
|
||||
constraints: {
|
||||
width: 640,
|
||||
height: 480,
|
||||
minAspectRatio: 0,
|
||||
maxAspectRatio: 100,
|
||||
facing: "environment" // or user
|
||||
},
|
||||
area: {
|
||||
top: "0%",
|
||||
right: "0%",
|
||||
left: "0%",
|
||||
bottom: "0%"
|
||||
},
|
||||
singleChannel: false // true: only the red color-channel is read
|
||||
},
|
||||
locate: true,
|
||||
numOfWorkers: 0,
|
||||
decoder: {
|
||||
readers: [
|
||||
'code_128_reader'
|
||||
],
|
||||
debug: {
|
||||
drawBoundingBox: false,
|
||||
showFrequency: false,
|
||||
drawScanline: false,
|
||||
showPattern: false
|
||||
}
|
||||
},
|
||||
locator: {
|
||||
halfSample: true,
|
||||
patchSize: "medium", // x-small, small, medium, large, x-large
|
||||
debug: {
|
||||
showCanvas: false,
|
||||
showPatches: false,
|
||||
showFoundPatches: false,
|
||||
showSkeleton: false,
|
||||
showLabels: false,
|
||||
showPatchLabels: false,
|
||||
showRemainingPatchLabels: false,
|
||||
boxFromPatches: {
|
||||
showTransformed: false,
|
||||
showTransformedBox: false,
|
||||
showBB: false
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
let config;
|
||||
|
||||
if (ENV.development){
|
||||
config = require('./config.dev.js');
|
||||
} else if (ENV.node) {
|
||||
config = require('./config.node.js');
|
||||
} else {
|
||||
config = require('./config.prod.js');
|
||||
}
|
||||
|
||||
export default config;
|
||||
@@ -0,0 +1,25 @@
|
||||
module.exports = {
|
||||
inputStream: {
|
||||
type: "ImageStream",
|
||||
sequence: false,
|
||||
size: 800,
|
||||
area: {
|
||||
top: "0%",
|
||||
right: "0%",
|
||||
left: "0%",
|
||||
bottom: "0%"
|
||||
},
|
||||
singleChannel: false // true: only the red color-channel is read
|
||||
},
|
||||
locate: true,
|
||||
numOfWorkers: 0,
|
||||
decoder: {
|
||||
readers: [
|
||||
'code_128_reader'
|
||||
]
|
||||
},
|
||||
locator: {
|
||||
halfSample: true,
|
||||
patchSize: "medium" // x-small, small, medium, large, x-large
|
||||
}
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
export default {
|
||||
module.exports = {
|
||||
inputStream: {
|
||||
name: "Live",
|
||||
type: "LiveStream",
|
||||
@@ -17,32 +17,15 @@ export default {
|
||||
},
|
||||
singleChannel: false // true: only the red color-channel is read
|
||||
},
|
||||
debug: false,
|
||||
locate: true,
|
||||
numOfWorkers: 4,
|
||||
decoder: {
|
||||
drawBoundingBox: false,
|
||||
showFrequency: false,
|
||||
drawScanline: false,
|
||||
showPattern: false,
|
||||
readers: [
|
||||
'code_128_reader'
|
||||
]
|
||||
},
|
||||
locator: {
|
||||
halfSample: true,
|
||||
patchSize: "medium", // x-small, small, medium, large, x-large
|
||||
showCanvas: false,
|
||||
showPatches: false,
|
||||
showFoundPatches: false,
|
||||
showSkeleton: false,
|
||||
showLabels: false,
|
||||
showPatchLabels: false,
|
||||
showRemainingPatchLabels: false,
|
||||
boxFromPatches: {
|
||||
showTransformed: false,
|
||||
showTransformedBox: false,
|
||||
showBB: false
|
||||
}
|
||||
patchSize: "medium" // x-small, small, medium, large, x-large
|
||||
}
|
||||
};
|
||||
@@ -1,14 +1,14 @@
|
||||
import Bresenham from './bresenham';
|
||||
import ImageDebug from './image_debug';
|
||||
import Code128Reader from './code_128_reader';
|
||||
import EANReader from './ean_reader';
|
||||
import Code39Reader from './code_39_reader';
|
||||
import Code39VINReader from './code_39_vin_reader';
|
||||
import CodabarReader from './codabar_reader';
|
||||
import UPCReader from './upc_reader';
|
||||
import EAN8Reader from './ean_8_reader';
|
||||
import UPCEReader from './upc_e_reader';
|
||||
import I2of5Reader from './i2of5_reader';
|
||||
import ImageDebug from '../common/image_debug';
|
||||
import Code128Reader from '../reader/code_128_reader';
|
||||
import EANReader from '../reader/ean_reader';
|
||||
import Code39Reader from '../reader/code_39_reader';
|
||||
import Code39VINReader from '../reader/code_39_vin_reader';
|
||||
import CodabarReader from '../reader/codabar_reader';
|
||||
import UPCReader from '../reader/upc_reader';
|
||||
import EAN8Reader from '../reader/ean_8_reader';
|
||||
import UPCEReader from '../reader/upc_e_reader';
|
||||
import I2of5Reader from '../reader/i2of5_reader';
|
||||
|
||||
const READERS = {
|
||||
code_128_reader: Code128Reader,
|
||||
@@ -42,7 +42,7 @@ export default {
|
||||
initConfig();
|
||||
|
||||
function initCanvas() {
|
||||
if (typeof document !== 'undefined') {
|
||||
if (ENV.development && typeof document !== 'undefined') {
|
||||
var $debug = document.querySelector("#debug.detection");
|
||||
_canvas.dom.frequency = document.querySelector("canvas.frequency");
|
||||
if (!_canvas.dom.frequency) {
|
||||
@@ -82,23 +82,27 @@ export default {
|
||||
} else if (typeof readerConfig === 'string') {
|
||||
reader = readerConfig;
|
||||
}
|
||||
console.log("Before registering reader: ", reader);
|
||||
if (ENV.development) {
|
||||
console.log("Before registering reader: ", reader);
|
||||
}
|
||||
_barcodeReaders.push(new READERS[reader](configuration));
|
||||
});
|
||||
console.log("Registered Readers: " + _barcodeReaders
|
||||
.map((reader) => JSON.stringify({format: reader.FORMAT, config: reader.config}))
|
||||
.join(', '));
|
||||
if (ENV.development) {
|
||||
console.log("Registered Readers: " + _barcodeReaders
|
||||
.map((reader) => JSON.stringify({format: reader.FORMAT, config: reader.config}))
|
||||
.join(', '));
|
||||
}
|
||||
}
|
||||
|
||||
function initConfig() {
|
||||
if (typeof document !== 'undefined') {
|
||||
if (ENV.development && typeof document !== 'undefined') {
|
||||
var i,
|
||||
vis = [{
|
||||
node: _canvas.dom.frequency,
|
||||
prop: config.showFrequency
|
||||
prop: config.debug.showFrequency
|
||||
}, {
|
||||
node: _canvas.dom.pattern,
|
||||
prop: config.showPattern
|
||||
prop: config.debug.showPattern
|
||||
}];
|
||||
|
||||
for (i = 0; i < vis.length; i++) {
|
||||
@@ -154,12 +158,14 @@ export default {
|
||||
i,
|
||||
barcodeLine = Bresenham.getBarcodeLine(inputImageWrapper, line[0], line[1]);
|
||||
|
||||
if (config.showFrequency) {
|
||||
if (ENV.development && config.debug.showFrequency) {
|
||||
ImageDebug.drawPath(line, {x: 'x', y: 'y'}, _canvas.ctx.overlay, {color: 'red', lineWidth: 3});
|
||||
Bresenham.debug.printFrequency(barcodeLine.line, _canvas.dom.frequency);
|
||||
}
|
||||
|
||||
Bresenham.toBinaryLine(barcodeLine);
|
||||
if (config.showPattern) {
|
||||
|
||||
if (ENV.development && config.debug.showPattern) {
|
||||
Bresenham.debug.printPattern(barcodeLine.line, _canvas.dom.pattern);
|
||||
}
|
||||
|
||||
@@ -228,8 +234,10 @@ export default {
|
||||
result,
|
||||
lineLength;
|
||||
|
||||
if (config.drawBoundingBox && ctx) {
|
||||
ImageDebug.drawPath(box, {x: 0, y: 1}, ctx, {color: "blue", lineWidth: 2});
|
||||
if (ENV.development) {
|
||||
if (config.debug.drawBoundingBox && ctx) {
|
||||
ImageDebug.drawPath(box, {x: 0, y: 1}, ctx, {color: "blue", lineWidth: 2});
|
||||
}
|
||||
}
|
||||
|
||||
line = getLine(box);
|
||||
@@ -249,7 +257,7 @@ export default {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (result && config.drawScanline && ctx) {
|
||||
if (ENV.development && result && config.debug.drawScanline && ctx) {
|
||||
ImageDebug.drawPath(line, {x: 'x', y: 'y'}, ctx, {color: 'red', lineWidth: 3});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import CVUtils from './cv_utils';
|
||||
import ImageWrapper from './image_wrapper';
|
||||
import CVUtils from '../common/cv_utils';
|
||||
import ImageWrapper from '../common/image_wrapper';
|
||||
|
||||
var Bresenham = {};
|
||||
|
||||
@@ -27,7 +27,9 @@ function loadedData(video, callback) {
|
||||
function checkVideo() {
|
||||
if (attempts > 0) {
|
||||
if (video.videoWidth > 0 && video.videoHeight > 0) {
|
||||
console.log(video.videoWidth + "px x " + video.videoHeight + "px");
|
||||
if (ENV.development) {
|
||||
console.log(video.videoWidth + "px x " + video.videoHeight + "px");
|
||||
}
|
||||
callback();
|
||||
} else {
|
||||
window.setTimeout(checkVideo, 500);
|
||||
@@ -1,4 +1,4 @@
|
||||
import CVUtils from './cv_utils';
|
||||
import CVUtils from '../common/cv_utils';
|
||||
|
||||
var FrameGrabber = {};
|
||||
|
||||
@@ -20,12 +20,14 @@ FrameGrabber.create = function(inputStream, canvas) {
|
||||
_canvas.height = _canvasSize.y;
|
||||
_ctx = _canvas.getContext("2d");
|
||||
_data = new Uint8Array(_size.x * _size.y);
|
||||
console.log("FrameGrabber", JSON.stringify({
|
||||
size: _size,
|
||||
topRight: topRight,
|
||||
videoSize: _video_size,
|
||||
canvasSize: _canvasSize
|
||||
}));
|
||||
if (ENV.development) {
|
||||
console.log("FrameGrabber", JSON.stringify({
|
||||
size: _size,
|
||||
topRight: topRight,
|
||||
videoSize: _video_size,
|
||||
canvasSize: _canvasSize
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the given array as frame-buffer
|
||||
@@ -34,7 +34,9 @@ ImageLoader.load = function(directory, callback, offset, size, sequence) {
|
||||
}
|
||||
}
|
||||
if (notloadedImgs.length === 0) {
|
||||
console.log("Images loaded");
|
||||
if (ENV.development) {
|
||||
console.log("Images loaded");
|
||||
}
|
||||
callback.apply(null, [htmlImagesArray]);
|
||||
}
|
||||
};
|
||||
@@ -1,11 +1,11 @@
|
||||
import ImageWrapper from './image_wrapper';
|
||||
import CVUtils from './cv_utils';
|
||||
import ImageWrapper from '../common/image_wrapper';
|
||||
import CVUtils from '../common/cv_utils';
|
||||
import ArrayHelper from '../common/array_helper';
|
||||
import ImageDebug from '../common/image_debug';
|
||||
import Rasterizer from './rasterizer';
|
||||
import Tracer from './tracer';
|
||||
import skeletonizer from './skeletonizer';
|
||||
import ArrayHelper from './array_helper';
|
||||
import ImageDebug from './image_debug';
|
||||
import glMatrix from 'gl-matrix';
|
||||
import {vec2, mat2} from 'gl-matrix';
|
||||
|
||||
var _config,
|
||||
_currentImageWrapper,
|
||||
@@ -27,9 +27,7 @@ var _config,
|
||||
},
|
||||
_numPatches = {x: 0, y: 0},
|
||||
_inputImageWrapper,
|
||||
_skeletonizer,
|
||||
vec2 = glMatrix.vec2,
|
||||
mat2 = glMatrix.mat2;
|
||||
_skeletonizer;
|
||||
|
||||
function initBuffers() {
|
||||
var skeletonImageData;
|
||||
@@ -76,7 +74,7 @@ function initCanvas() {
|
||||
}
|
||||
_canvasContainer.dom.binary = document.createElement("canvas");
|
||||
_canvasContainer.dom.binary.className = "binaryBuffer";
|
||||
if (_config.showCanvas === true) {
|
||||
if (ENV.development && _config.debug.showCanvas === true) {
|
||||
document.querySelector("#debug").appendChild(_canvasContainer.dom.binary);
|
||||
}
|
||||
_canvasContainer.ctx.binary = _canvasContainer.dom.binary.getContext("2d");
|
||||
@@ -107,7 +105,7 @@ function boxFromPatches(patches) {
|
||||
for ( i = 0; i < patches.length; i++) {
|
||||
patch = patches[i];
|
||||
overAvg += patch.rad;
|
||||
if (_config.showPatches) {
|
||||
if (ENV.development && _config.debug.showPatches) {
|
||||
ImageDebug.drawRect(patch.pos, _subImageWrapper.size, _canvasContainer.ctx.binary, {color: "red"});
|
||||
}
|
||||
}
|
||||
@@ -128,7 +126,7 @@ function boxFromPatches(patches) {
|
||||
vec2.transformMat2(patch.box[j], patch.box[j], transMat);
|
||||
}
|
||||
|
||||
if (_config.boxFromPatches.showTransformed) {
|
||||
if (ENV.development && _config.debug.boxFromPatches.showTransformed) {
|
||||
ImageDebug.drawPath(patch.box, {x: 0, y: 1}, _canvasContainer.ctx.binary, {color: '#99ff00', lineWidth: 2});
|
||||
}
|
||||
}
|
||||
@@ -154,7 +152,7 @@ function boxFromPatches(patches) {
|
||||
|
||||
box = [[minx, miny], [maxx, miny], [maxx, maxy], [minx, maxy]];
|
||||
|
||||
if (_config.boxFromPatches.showTransformedBox) {
|
||||
if (ENV.development && _config.debug.boxFromPatches.showTransformedBox) {
|
||||
ImageDebug.drawPath(box, {x: 0, y: 1}, _canvasContainer.ctx.binary, {color: '#ff0000', lineWidth: 2});
|
||||
}
|
||||
|
||||
@@ -165,7 +163,7 @@ function boxFromPatches(patches) {
|
||||
vec2.transformMat2(box[j], box[j], transMat);
|
||||
}
|
||||
|
||||
if (_config.boxFromPatches.showBB) {
|
||||
if (ENV.development && _config.debug.boxFromPatches.showBB) {
|
||||
ImageDebug.drawPath(box, {x: 0, y: 1}, _canvasContainer.ctx.binary, {color: '#ff0000', lineWidth: 2});
|
||||
}
|
||||
|
||||
@@ -215,7 +213,7 @@ function findPatches() {
|
||||
rasterizer = Rasterizer.create(_skelImageWrapper, _labelImageWrapper);
|
||||
rasterResult = rasterizer.rasterize(0);
|
||||
|
||||
if (_config.showLabels) {
|
||||
if (ENV.development && _config.debug.showLabels) {
|
||||
_labelImageWrapper.overlay(_canvasContainer.dom.binary, Math.floor(360 / rasterResult.count),
|
||||
{x: x, y: y});
|
||||
}
|
||||
@@ -228,7 +226,7 @@ function findPatches() {
|
||||
}
|
||||
}
|
||||
|
||||
if (_config.showFoundPatches) {
|
||||
if (ENV.development && _config.debug.showFoundPatches) {
|
||||
for ( i = 0; i < patchesFound.length; i++) {
|
||||
patch = patchesFound[i];
|
||||
ImageDebug.drawRect(patch.pos, _subImageWrapper.size, _canvasContainer.ctx.binary,
|
||||
@@ -307,7 +305,7 @@ function findBoxes(topLabels, maxLabel) {
|
||||
boxes.push(box);
|
||||
|
||||
// draw patch-labels if requested
|
||||
if (_config.showRemainingPatchLabels) {
|
||||
if (ENV.development && _config.debug.showRemainingPatchLabels) {
|
||||
for ( j = 0; j < patches.length; j++) {
|
||||
patch = patches[j];
|
||||
hsv[0] = (topLabels[i].label / (maxLabel + 1)) * 360;
|
||||
@@ -345,7 +343,7 @@ function skeletonize(x, y) {
|
||||
_skeletonizer.skeletonize();
|
||||
|
||||
// Show skeleton if requested
|
||||
if (_config.showSkeleton) {
|
||||
if (ENV.development && _config.debug.showSkeleton) {
|
||||
_skelImageWrapper.overlay(_canvasContainer.dom.binary, 360, CVUtils.imageRef(x, y));
|
||||
}
|
||||
}
|
||||
@@ -493,7 +491,7 @@ function rasterizeAngularSimilarity(patchesFound) {
|
||||
}
|
||||
|
||||
// draw patch-labels if requested
|
||||
if (_config.showPatchLabels) {
|
||||
if (ENV.development && _config.debug.showPatchLabels) {
|
||||
for ( j = 0; j < _patchLabelGrid.data.length; j++) {
|
||||
if (_patchLabelGrid.data[j] > 0 && _patchLabelGrid.data[j] <= label) {
|
||||
patch = _imageToPatchGrid.data[j];
|
||||
@@ -572,7 +570,9 @@ export default {
|
||||
};
|
||||
|
||||
patchSize = CVUtils.calculatePatchSize(config.patchSize, size);
|
||||
console.log("Patch-Size: " + JSON.stringify(patchSize));
|
||||
if (ENV.development) {
|
||||
console.log("Patch-Size: " + JSON.stringify(patchSize));
|
||||
}
|
||||
|
||||
inputStream.setWidth(Math.floor(Math.floor(size.x / patchSize.x) * (1 / halfSample) * patchSize.x));
|
||||
inputStream.setHeight(Math.floor(Math.floor(size.y / patchSize.y) * (1 / halfSample) * patchSize.y));
|
||||
+27
-17
@@ -1,17 +1,17 @@
|
||||
import TypeDefs from './typedefs'; // eslint-disable-line no-unused-vars
|
||||
import ImageWrapper from './image_wrapper';
|
||||
import BarcodeLocator from './barcode_locator';
|
||||
import BarcodeDecoder from './barcode_decoder';
|
||||
import Config from './config';
|
||||
import Events from './events';
|
||||
import CameraAccess from './camera_access';
|
||||
import ImageDebug from './image_debug';
|
||||
import TypeDefs from './common/typedefs'; // eslint-disable-line no-unused-vars
|
||||
import ImageWrapper from './common/image_wrapper';
|
||||
import BarcodeLocator from './locator/barcode_locator';
|
||||
import BarcodeDecoder from './decoder/barcode_decoder';
|
||||
import Events from './common/events';
|
||||
import CameraAccess from './input/camera_access';
|
||||
import ImageDebug from './common/image_debug';
|
||||
import {vec2} from 'gl-matrix';
|
||||
import ResultCollector from './result_collector';
|
||||
import ResultCollector from './analytics/result_collector';
|
||||
import Config from './config/config';
|
||||
import InputStream from 'input_stream';
|
||||
import FrameGrabber from 'frame_grabber';
|
||||
|
||||
const merge = require('lodash/object/merge');
|
||||
const InputStream = require('input_stream');
|
||||
const FrameGrabber = require('frame_grabber');
|
||||
|
||||
var _inputStream,
|
||||
_framegrabber,
|
||||
@@ -90,7 +90,9 @@ function canRecord(cb) {
|
||||
|
||||
if (_config.numOfWorkers > 0) {
|
||||
initWorkers(function() {
|
||||
console.log("Workers created");
|
||||
if (ENV.development) {
|
||||
console.log("Workers created");
|
||||
}
|
||||
ready(cb);
|
||||
});
|
||||
} else {
|
||||
@@ -148,7 +150,9 @@ function initBuffers(imageWrapper) {
|
||||
});
|
||||
}
|
||||
|
||||
console.log(_inputImageWrapper.size);
|
||||
if (ENV.development) {
|
||||
console.log(_inputImageWrapper.size);
|
||||
}
|
||||
_boxSize = [
|
||||
vec2.clone([0, 0]),
|
||||
vec2.clone([0, _inputImageWrapper.size.y]),
|
||||
@@ -341,14 +345,18 @@ function initWorker(cb) {
|
||||
URL.revokeObjectURL(blobURL);
|
||||
workerThread.busy = false;
|
||||
workerThread.imageData = new Uint8Array(e.data.imageData);
|
||||
console.log("Worker initialized");
|
||||
if (ENV.development) {
|
||||
console.log("Worker initialized");
|
||||
}
|
||||
return cb(workerThread);
|
||||
} else if (e.data.event === 'processed') {
|
||||
workerThread.imageData = new Uint8Array(e.data.imageData);
|
||||
workerThread.busy = false;
|
||||
publishResult(e.data.result, workerThread.imageData);
|
||||
} else if (e.data.event === 'error') {
|
||||
console.log("Worker error: " + e.data.message);
|
||||
if (ENV.development) {
|
||||
console.log("Worker error: " + e.data.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -449,7 +457,9 @@ export default {
|
||||
_stopped = true;
|
||||
_workerPool.forEach(function(workerThread) {
|
||||
workerThread.worker.terminate();
|
||||
console.log("Worker terminated!");
|
||||
if (ENV.development) {
|
||||
console.log("Worker terminated!");
|
||||
}
|
||||
});
|
||||
_workerPool.length = 0;
|
||||
if (_config.inputStream.type === "LiveStream") {
|
||||
@@ -489,7 +499,7 @@ export default {
|
||||
size: 800,
|
||||
src: config.src
|
||||
},
|
||||
numOfWorkers: 1,
|
||||
numOfWorkers: (ENV.development && config.debug) ? 0 : 1,
|
||||
locator: {
|
||||
halfSample: false
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import BarcodeReader from './barcode_reader';
|
||||
import ArrayHelper from './array_helper';
|
||||
import ArrayHelper from '../common/array_helper';
|
||||
|
||||
function Code39Reader() {
|
||||
BarcodeReader.call(this);
|
||||
@@ -29,7 +29,9 @@ Code39VINReader.prototype._decode = function() {
|
||||
code = code.replace(patterns.IOQ, '');
|
||||
|
||||
if (!code.match(patterns.AZ09)) {
|
||||
console.log('Failed AZ09 pattern code:', code);
|
||||
if (ENV.development) {
|
||||
console.log('Failed AZ09 pattern code:', code);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+6
-2
@@ -16,9 +16,10 @@ module.exports = {
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['', '.js', '.jsx'],
|
||||
root: path.resolve(__dirname),
|
||||
alias: {
|
||||
'input_stream$': path.resolve(__dirname, 'src/input_stream'),
|
||||
'frame_grabber$': path.resolve(__dirname, 'src/frame_grabber')
|
||||
'input_stream$': 'src/input/input_stream',
|
||||
'frame_grabber$': 'src/input/frame_grabber'
|
||||
}
|
||||
},
|
||||
output: {
|
||||
@@ -33,6 +34,9 @@ module.exports = {
|
||||
plugins: [
|
||||
new MyUmdPlugin({
|
||||
library: 'Quagga'
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
ENV: require(path.join(__dirname, './env/', process.env.BUILD_ENV))
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
@@ -5,9 +5,10 @@ module.exports = require('./webpack.config.js');
|
||||
|
||||
module.exports.resolve = {
|
||||
extensions: ['', '.js', '.jsx'],
|
||||
root: path.resolve(__dirname),
|
||||
alias: {
|
||||
'input_stream$': path.resolve(__dirname, 'lib/input_stream'),
|
||||
'frame_grabber$': path.resolve(__dirname, 'lib/frame_grabber')
|
||||
'input_stream': 'lib/input_stream',
|
||||
'frame_grabber': 'lib/frame_grabber'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,6 +20,10 @@ module.exports.externals = [
|
||||
"ndarray-linear-interpolate"
|
||||
];
|
||||
module.exports.output.libraryTarget = "commonjs2";
|
||||
module.exports.plugins = [];
|
||||
module.exports.plugins = [
|
||||
new webpack.DefinePlugin({
|
||||
ENV: require(path.join(__dirname, './env/', process.env.BUILD_ENV))
|
||||
})
|
||||
];
|
||||
module.exports.output.path = __dirname + '/lib';
|
||||
module.exports.output.filename = 'quagga.js';
|
||||
|
||||
Reference in New Issue
Block a user