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