mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-12 21:21:42 +08:00
Restructuring builds; Moved debug-config
This commit is contained in:
Vendored
+91
-141
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
+138
-50
File diff suppressed because one or more lines are too long
+4
-1
@@ -40,7 +40,10 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "grunt test",
|
"test": "grunt test",
|
||||||
"integrationtest": "grunt integrationtest",
|
"integrationtest": "grunt integrationtest",
|
||||||
"build:dev": "webpack && webpack --config webpack.config.min.js && grunt uglyasm && webpack --config webpack.node.config.js",
|
"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",
|
"watch": "cross-env BUILD_ENV=development webpack --watch",
|
||||||
"lint": "eslint src"
|
"lint": "eslint src"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -158,7 +158,9 @@ export default {
|
|||||||
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 (ENV.development && config.debug.showPattern) {
|
if (ENV.development && config.debug.showPattern) {
|
||||||
Bresenham.debug.printPattern(barcodeLine.line, _canvas.dom.pattern);
|
Bresenham.debug.printPattern(barcodeLine.line, _canvas.dom.pattern);
|
||||||
}
|
}
|
||||||
@@ -251,7 +253,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});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ 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 glMatrix from 'gl-matrix';
|
import {vec2, mat2} 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.development.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];
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
import TypeDefs from './typedefs'; // eslint-disable-line no-unused-vars
|
import TypeDefs from './common/typedefs'; // eslint-disable-line no-unused-vars
|
||||||
import ImageWrapper from './common/image_wrapper';
|
import ImageWrapper from './common/image_wrapper';
|
||||||
import BarcodeLocator from './locator/barcode_locator';
|
import BarcodeLocator from './locator/barcode_locator';
|
||||||
import BarcodeDecoder from './decoder/barcode_decoder';
|
import BarcodeDecoder from './decoder/barcode_decoder';
|
||||||
@@ -489,6 +489,7 @@ export default {
|
|||||||
size: 800,
|
size: 800,
|
||||||
src: config.src
|
src: config.src
|
||||||
},
|
},
|
||||||
|
numOfWorkers: ENV.development ? 0 : 1,
|
||||||
locator: {
|
locator: {
|
||||||
halfSample: false
|
halfSample: false
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -17,8 +17,8 @@ module.exports = {
|
|||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['', '.js', '.jsx'],
|
extensions: ['', '.js', '.jsx'],
|
||||||
alias: {
|
alias: {
|
||||||
'input_stream$': path.resolve(__dirname, 'src/input_stream'),
|
'input_stream$': path.resolve(__dirname, 'src/input/input_stream'),
|
||||||
'frame_grabber$': path.resolve(__dirname, 'src/frame_grabber')
|
'frame_grabber$': path.resolve(__dirname, 'src/input/frame_grabber')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
Reference in New Issue
Block a user