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
+134
-62
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"]
|
||||
},
|
||||
|
||||
+3
-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,8 @@
|
||||
"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": "webpack && webpack --config webpack.config.min.js && grunt uglyasm && webpack --config webpack.node.config.js",
|
||||
"watch": "cross-env BUILD_ENV=development webpack --watch",
|
||||
"lint": "eslint src"
|
||||
},
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
+11
-47
@@ -1,48 +1,12 @@
|
||||
export default {
|
||||
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
|
||||
},
|
||||
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
|
||||
let config;
|
||||
|
||||
console.log(ENV);
|
||||
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
|
||||
}
|
||||
};
|
||||
@@ -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,
|
||||
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 +154,12 @@ 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,9 +228,11 @@ export default {
|
||||
result,
|
||||
lineLength;
|
||||
|
||||
if (config.drawBoundingBox && ctx) {
|
||||
if (ENV.development) {
|
||||
if (config.debug.drawBoundingBox && ctx) {
|
||||
ImageDebug.drawPath(box, {x: 0, y: 1}, ctx, {color: "blue", lineWidth: 2});
|
||||
}
|
||||
}
|
||||
|
||||
line = getLine(box);
|
||||
lineLength = getLineLength(line);
|
||||
|
||||
@@ -489,7 +489,6 @@ export default {
|
||||
size: 800,
|
||||
src: config.src
|
||||
},
|
||||
numOfWorkers: 1,
|
||||
locator: {
|
||||
halfSample: false
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ module.exports = {
|
||||
plugins: [
|
||||
new MyUmdPlugin({
|
||||
library: 'Quagga'
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
ENV: require(path.join(__dirname, './env/', process.env.BUILD_ENV))
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user