mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-12 21:21:42 +08:00
Added ENV for dead-code elimination in production mode
This commit is contained in:
Vendored
+136
-64
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"]
|
||||||
},
|
},
|
||||||
|
|||||||
+3
-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,8 @@
|
|||||||
"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": "webpack && webpack --config webpack.config.min.js && grunt uglyasm && webpack --config webpack.node.config.js",
|
||||||
"watch": "webpack --watch",
|
"watch": "cross-env BUILD_ENV=development webpack --watch",
|
||||||
"lint": "eslint src"
|
"lint": "eslint src"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -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: true,
|
||||||
|
showPatches: true,
|
||||||
|
showFoundPatches: false,
|
||||||
|
showSkeleton: false,
|
||||||
|
showLabels: false,
|
||||||
|
showPatchLabels: false,
|
||||||
|
showRemainingPatchLabels: false,
|
||||||
|
boxFromPatches: {
|
||||||
|
showTransformed: false,
|
||||||
|
showTransformedBox: false,
|
||||||
|
showBB: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
+12
-48
@@ -1,48 +1,12 @@
|
|||||||
export default {
|
let config;
|
||||||
inputStream: {
|
|
||||||
name: "Live",
|
console.log(ENV);
|
||||||
type: "LiveStream",
|
if(ENV.development){
|
||||||
constraints: {
|
config = require('./config.dev.js');
|
||||||
width: 640,
|
} else if (ENV.node) {
|
||||||
height: 480,
|
config = require('./config.node.js');
|
||||||
minAspectRatio: 0,
|
} else {
|
||||||
maxAspectRatio: 100,
|
config = require('./config.prod.js');
|
||||||
facing: "environment" // or user
|
}
|
||||||
},
|
|
||||||
area: {
|
export default config;
|
||||||
top: "0%",
|
|
||||||
right: "0%",
|
|
||||||
left: "0%",
|
|
||||||
bottom: "0%"
|
|
||||||
},
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
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: 4,
|
||||||
|
decoder: {
|
||||||
|
readers: [
|
||||||
|
'code_128_reader'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
locator: {
|
||||||
|
halfSample: true,
|
||||||
|
patchSize: "medium", // x-small, small, medium, large, x-large
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -95,10 +95,10 @@ export default {
|
|||||||
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 +154,12 @@ 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 +228,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);
|
||||||
|
|||||||
@@ -489,7 +489,6 @@ export default {
|
|||||||
size: 800,
|
size: 800,
|
||||||
src: config.src
|
src: config.src
|
||||||
},
|
},
|
||||||
numOfWorkers: 1,
|
|
||||||
locator: {
|
locator: {
|
||||||
halfSample: false
|
halfSample: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,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))
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user