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:
@@ -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 {
|
||||
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,8 +228,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);
|
||||
|
||||
@@ -489,7 +489,6 @@ export default {
|
||||
size: 800,
|
||||
src: config.src
|
||||
},
|
||||
numOfWorkers: 1,
|
||||
locator: {
|
||||
halfSample: false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user