mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-12 21:21:42 +08:00
Initial migration to webpack
This commit is contained in:
@@ -11,49 +11,8 @@ module.exports = function(grunt) {
|
|||||||
configFile: 'karma-integration.conf.js'
|
configFile: 'karma-integration.conf.js'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
uglify : {
|
|
||||||
options : {
|
|
||||||
banner : '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
|
|
||||||
preserveComments: 'some'
|
|
||||||
},
|
|
||||||
build : {
|
|
||||||
src : 'dist/<%= pkg.name %>.js',
|
|
||||||
dest : 'dist/<%= pkg.name %>.min.js'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
jshint : {
|
jshint : {
|
||||||
all : ['Gruntfile.js', 'src/*.js']
|
all : ['Gruntfile.js', 'src/*.js']
|
||||||
},
|
|
||||||
requirejs : {
|
|
||||||
compile : {
|
|
||||||
options : {
|
|
||||||
almond : true,
|
|
||||||
wrap : {
|
|
||||||
startFile : 'build/start.frag',
|
|
||||||
endFile : 'build/end.frag'
|
|
||||||
},
|
|
||||||
"baseUrl" : "src",
|
|
||||||
"name" : "quagga",
|
|
||||||
"useStrict": true,
|
|
||||||
"out" : "dist/quagga.js",
|
|
||||||
"include" : ['quagga'],
|
|
||||||
"optimize" : "none",
|
|
||||||
"findNestedDependencies" : true,
|
|
||||||
"skipSemiColonInsertion" : true,
|
|
||||||
|
|
||||||
"shim" : {
|
|
||||||
"typedefs" : {
|
|
||||||
"deps" : [],
|
|
||||||
"exports" : "typedefs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"paths" : {
|
|
||||||
"typedefs" : "typedefs",
|
|
||||||
"gl-matrix": "../node_modules/gl-matrix/dist/gl-matrix-min"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Vendored
+10689
-4685
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+7
-10
File diff suppressed because one or more lines are too long
+8
-3
@@ -6,6 +6,9 @@
|
|||||||
"browser": "dist/quagga.js",
|
"browser": "dist/quagga.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"async": "^1.4.2",
|
"async": "^1.4.2",
|
||||||
|
"babel-core": "^5.8.25",
|
||||||
|
"babel-eslint": "^4.1.3",
|
||||||
|
"babel-loader": "^5.3.2",
|
||||||
"chai": "^3.2.0",
|
"chai": "^3.2.0",
|
||||||
"grunt": "^0.4.5",
|
"grunt": "^0.4.5",
|
||||||
"grunt-contrib-jshint": "^0.11.3",
|
"grunt-contrib-jshint": "^0.11.3",
|
||||||
@@ -23,7 +26,9 @@
|
|||||||
"karma-sinon": "^1.0.4",
|
"karma-sinon": "^1.0.4",
|
||||||
"karma-sinon-chai": "~0.2.0",
|
"karma-sinon-chai": "~0.2.0",
|
||||||
"mocha": "^2.3.2",
|
"mocha": "^2.3.2",
|
||||||
"sinon": "^1.16.1"
|
"sinon": "^1.16.1",
|
||||||
|
"webpack": "^1.12.2",
|
||||||
|
"webpack-core": "^0.6.7"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"doc": "doc"
|
"doc": "doc"
|
||||||
@@ -56,8 +61,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"get-pixels": "^3.2.3",
|
"get-pixels": "^3.2.3",
|
||||||
"gl-matrix": "^2.3.1",
|
"gl-matrix": "^2.3.1",
|
||||||
|
"lodash": "^3.10.1",
|
||||||
"ndarray": "^1.0.18",
|
"ndarray": "^1.0.18",
|
||||||
"ndarray-linear-interpolate": "^1.0.0",
|
"ndarray-linear-interpolate": "^1.0.0"
|
||||||
"requirejs": "^2.1.20"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
var ConcatSource = require("webpack-core/lib/ConcatSource");
|
||||||
|
var OriginalSource = require("webpack-core/lib/OriginalSource");
|
||||||
|
|
||||||
|
function MyUmdPlugin(options) {
|
||||||
|
this.name = options.library;
|
||||||
|
console.log(this.name);
|
||||||
|
}
|
||||||
|
module.exports = MyUmdPlugin;
|
||||||
|
MyUmdPlugin.prototype.apply = function(compiler) {
|
||||||
|
compiler.plugin("this-compilation", function(compilation) {
|
||||||
|
var mainTemplate = compilation.mainTemplate;
|
||||||
|
console.log("Compilation: " + (typeof compilation.templatesPlugin));
|
||||||
|
compilation.templatesPlugin("render-with-entry", function(source, chunk, hash) {
|
||||||
|
|
||||||
|
var amdFactory = "factory";
|
||||||
|
return new ConcatSource(new OriginalSource(
|
||||||
|
"(function webpackUniversalModuleDefinition(root, factory) {\n" +
|
||||||
|
" if(typeof exports === 'object' && typeof module === 'object')\n" +
|
||||||
|
" module.exports = factory(factory.toString());\n" +
|
||||||
|
" else if(typeof exports === 'object')\n" +
|
||||||
|
" exports[\"" + this.name + "\"] = factory(factory.toString());\n" +
|
||||||
|
" else\n" +
|
||||||
|
" root[\"" + this.name + "\"] = factory(factory.toString());\n" +
|
||||||
|
"})(this, function(__factorySource__) {\nreturn ", "webpack/myModuleDefinition"), source, "\n});\n");
|
||||||
|
}.bind(this));
|
||||||
|
mainTemplate.plugin("global-hash-paths", function(paths) {
|
||||||
|
if(this.name) paths = paths.concat(this.name);
|
||||||
|
return paths;
|
||||||
|
}.bind(this));
|
||||||
|
mainTemplate.plugin("hash", function(hash) {
|
||||||
|
hash.update("umd");
|
||||||
|
hash.update(this.name + "");
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
};
|
||||||
+2
-9
@@ -1,10 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
export default {
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
return {
|
|
||||||
init : function(arr, val) {
|
init : function(arr, val) {
|
||||||
var l = arr.length;
|
var l = arr.length;
|
||||||
while (l--) {
|
while (l--) {
|
||||||
@@ -82,5 +76,4 @@ define(function() {
|
|||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|||||||
+15
-35
@@ -1,33 +1,16 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import Bresenham from './bresenham';
|
||||||
/* global define */
|
import ImageDebug from './image_debug';
|
||||||
|
import Code128Reader from './code_128_reader';
|
||||||
|
import EANReader from './ean_reader';
|
||||||
|
import Code39Reader from './code_39_reader';
|
||||||
|
import Code39VINReader from './code_39_vin_reader';
|
||||||
|
import CodabarReader from './codabar_reader';
|
||||||
|
import UPCReader from './upc_reader';
|
||||||
|
import EAN8Reader from './ean_8_reader';
|
||||||
|
import UPCEReader from './upc_e_reader';
|
||||||
|
import I2of5Reader from './i2of5_reader';
|
||||||
|
|
||||||
define([
|
var readers = {
|
||||||
"bresenham",
|
|
||||||
"image_debug",
|
|
||||||
'code_128_reader',
|
|
||||||
'ean_reader',
|
|
||||||
'code_39_reader',
|
|
||||||
'code_39_vin_reader',
|
|
||||||
'codabar_reader',
|
|
||||||
'upc_reader',
|
|
||||||
'ean_8_reader',
|
|
||||||
'upc_e_reader',
|
|
||||||
'i2of5_reader'
|
|
||||||
], function(
|
|
||||||
Bresenham,
|
|
||||||
ImageDebug,
|
|
||||||
Code128Reader,
|
|
||||||
EANReader,
|
|
||||||
Code39Reader,
|
|
||||||
Code39VINReader,
|
|
||||||
CodabarReader,
|
|
||||||
UPCReader,
|
|
||||||
EAN8Reader,
|
|
||||||
UPCEReader,
|
|
||||||
I2of5Reader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var readers = {
|
|
||||||
code_128_reader: Code128Reader,
|
code_128_reader: Code128Reader,
|
||||||
ean_reader: EANReader,
|
ean_reader: EANReader,
|
||||||
ean_8_reader: EAN8Reader,
|
ean_8_reader: EAN8Reader,
|
||||||
@@ -37,8 +20,8 @@ define([
|
|||||||
upc_reader: UPCReader,
|
upc_reader: UPCReader,
|
||||||
upc_e_reader: UPCEReader,
|
upc_e_reader: UPCEReader,
|
||||||
i2of5_reader: I2of5Reader
|
i2of5_reader: I2of5Reader
|
||||||
};
|
};
|
||||||
var BarcodeDecoder = {
|
export default {
|
||||||
create : function(config, inputImageWrapper) {
|
create : function(config, inputImageWrapper) {
|
||||||
var _canvas = {
|
var _canvas = {
|
||||||
ctx : {
|
ctx : {
|
||||||
@@ -299,7 +282,4 @@ define([
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (BarcodeDecoder);
|
|
||||||
});
|
|
||||||
|
|||||||
+42
-38
@@ -1,10 +1,16 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
/* jshint undef: true, unused: true, browser:true, devel: true */
|
||||||
/* global define */
|
/* global define */
|
||||||
|
|
||||||
define("barcode_locator", ["image_wrapper", "cv_utils", "rasterizer", "tracer", "skeletonizer", "array_helper", "image_debug", "gl-matrix"],
|
import ImageWrapper from './image_wrapper';
|
||||||
function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, ImageDebug, glMatrix) {
|
import CVUtils from './cv_utils';
|
||||||
|
import Rasterizer from './rasterizer';
|
||||||
|
import Tracer from './tracer';
|
||||||
|
import skeletonizer from './skeletonizer';
|
||||||
|
import ArrayHelper from './array_helper';
|
||||||
|
import ImageDebug from './image_debug';
|
||||||
|
import glMatrix from 'gl-matrix';
|
||||||
|
|
||||||
var _config,
|
var _config,
|
||||||
_currentImageWrapper,
|
_currentImageWrapper,
|
||||||
_skelImageWrapper,
|
_skelImageWrapper,
|
||||||
_subImageWrapper,
|
_subImageWrapper,
|
||||||
@@ -27,9 +33,9 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
_skeletonizer,
|
_skeletonizer,
|
||||||
vec2 = glMatrix.vec2,
|
vec2 = glMatrix.vec2,
|
||||||
mat2 = glMatrix.mat2,
|
mat2 = glMatrix.mat2,
|
||||||
self = this;
|
self = (typeof window !== 'undefined') ? window : self;
|
||||||
|
|
||||||
function initBuffers() {
|
function initBuffers() {
|
||||||
var skeletonImageData;
|
var skeletonImageData;
|
||||||
|
|
||||||
if (_config.halfSample) {
|
if (_config.halfSample) {
|
||||||
@@ -63,9 +69,9 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
}, undefined, Array, true);
|
}, undefined, Array, true);
|
||||||
_patchGrid = new ImageWrapper(_imageToPatchGrid.size, undefined, undefined, true);
|
_patchGrid = new ImageWrapper(_imageToPatchGrid.size, undefined, undefined, true);
|
||||||
_patchLabelGrid = new ImageWrapper(_imageToPatchGrid.size, undefined, Int32Array, true);
|
_patchLabelGrid = new ImageWrapper(_imageToPatchGrid.size, undefined, Int32Array, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initCanvas() {
|
function initCanvas() {
|
||||||
if (_config.useWorker || typeof document === 'undefined') {
|
if (_config.useWorker || typeof document === 'undefined') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -77,13 +83,13 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
_canvasContainer.ctx.binary = _canvasContainer.dom.binary.getContext("2d");
|
_canvasContainer.ctx.binary = _canvasContainer.dom.binary.getContext("2d");
|
||||||
_canvasContainer.dom.binary.width = _binaryImageWrapper.size.x;
|
_canvasContainer.dom.binary.width = _binaryImageWrapper.size.x;
|
||||||
_canvasContainer.dom.binary.height = _binaryImageWrapper.size.y;
|
_canvasContainer.dom.binary.height = _binaryImageWrapper.size.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a bounding box which encloses all the given patches
|
* Creates a bounding box which encloses all the given patches
|
||||||
* @returns {Array} The minimal bounding box
|
* @returns {Array} The minimal bounding box
|
||||||
*/
|
*/
|
||||||
function boxFromPatches(patches) {
|
function boxFromPatches(patches) {
|
||||||
var overAvg, i, j, patch, transMat, minx = _binaryImageWrapper.size.x, miny = _binaryImageWrapper.size.y, maxx = -_binaryImageWrapper.size.x, maxy = -_binaryImageWrapper.size.y, box, scale;
|
var overAvg, i, j, patch, transMat, minx = _binaryImageWrapper.size.x, miny = _binaryImageWrapper.size.y, maxx = -_binaryImageWrapper.size.x, maxy = -_binaryImageWrapper.size.y, box, scale;
|
||||||
|
|
||||||
// draw all patches which are to be taken into consideration
|
// draw all patches which are to be taken into consideration
|
||||||
@@ -158,24 +164,24 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a binary image of the current image
|
* Creates a binary image of the current image
|
||||||
*/
|
*/
|
||||||
function binarizeImage() {
|
function binarizeImage() {
|
||||||
CVUtils.otsuThreshold(_currentImageWrapper, _binaryImageWrapper);
|
CVUtils.otsuThreshold(_currentImageWrapper, _binaryImageWrapper);
|
||||||
_binaryImageWrapper.zeroBorder();
|
_binaryImageWrapper.zeroBorder();
|
||||||
if (_config.showCanvas) {
|
if (_config.showCanvas) {
|
||||||
_binaryImageWrapper.show(_canvasContainer.dom.binary, 255);
|
_binaryImageWrapper.show(_canvasContainer.dom.binary, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterate over the entire image
|
* Iterate over the entire image
|
||||||
* extract patches
|
* extract patches
|
||||||
*/
|
*/
|
||||||
function findPatches() {
|
function findPatches() {
|
||||||
var i,
|
var i,
|
||||||
j,
|
j,
|
||||||
x,
|
x,
|
||||||
@@ -220,14 +226,14 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
return patchesFound;
|
return patchesFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds those connected areas which contain at least 6 patches
|
* Finds those connected areas which contain at least 6 patches
|
||||||
* and returns them ordered DESC by the number of contained patches
|
* and returns them ordered DESC by the number of contained patches
|
||||||
* @param {Number} maxLabel
|
* @param {Number} maxLabel
|
||||||
*/
|
*/
|
||||||
function findBiggestConnectedAreas(maxLabel){
|
function findBiggestConnectedAreas(maxLabel){
|
||||||
var i,
|
var i,
|
||||||
sum,
|
sum,
|
||||||
labelHist = [],
|
labelHist = [],
|
||||||
@@ -260,12 +266,12 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
});
|
});
|
||||||
|
|
||||||
return topLabels;
|
return topLabels;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function findBoxes(topLabels, maxLabel) {
|
function findBoxes(topLabels, maxLabel) {
|
||||||
var i,
|
var i,
|
||||||
j,
|
j,
|
||||||
sum,
|
sum,
|
||||||
@@ -301,13 +307,13 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return boxes;
|
return boxes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find similar moments (via cluster)
|
* Find similar moments (via cluster)
|
||||||
* @param {Object} moments
|
* @param {Object} moments
|
||||||
*/
|
*/
|
||||||
function similarMoments(moments) {
|
function similarMoments(moments) {
|
||||||
var clusters = CVUtils.cluster(moments, 0.90);
|
var clusters = CVUtils.cluster(moments, 0.90);
|
||||||
var topCluster = CVUtils.topGeneric(clusters, 1, function(e) {
|
var topCluster = CVUtils.topGeneric(clusters, 1, function(e) {
|
||||||
return e.getPoints().length;
|
return e.getPoints().length;
|
||||||
@@ -320,9 +326,9 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function skeletonize(x, y) {
|
function skeletonize(x, y) {
|
||||||
_binaryImageWrapper.subImageAsCopy(_subImageWrapper, CVUtils.imageRef(x, y));
|
_binaryImageWrapper.subImageAsCopy(_subImageWrapper, CVUtils.imageRef(x, y));
|
||||||
_skeletonizer.skeletonize();
|
_skeletonizer.skeletonize();
|
||||||
|
|
||||||
@@ -330,9 +336,9 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
if (_config.showSkeleton) {
|
if (_config.showSkeleton) {
|
||||||
_skelImageWrapper.overlay(_canvasContainer.dom.binary, 360, CVUtils.imageRef(x, y));
|
_skelImageWrapper.overlay(_canvasContainer.dom.binary, 360, CVUtils.imageRef(x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts and describes those patches which seem to contain a barcode pattern
|
* Extracts and describes those patches which seem to contain a barcode pattern
|
||||||
* @param {Array} moments
|
* @param {Array} moments
|
||||||
* @param {Object} patchPos,
|
* @param {Object} patchPos,
|
||||||
@@ -340,7 +346,7 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
* @returns {Array} list of patches
|
* @returns {Array} list of patches
|
||||||
*/
|
*/
|
||||||
function describePatch(moments, patchPos, x, y) {
|
function describePatch(moments, patchPos, x, y) {
|
||||||
var k,
|
var k,
|
||||||
avg,
|
avg,
|
||||||
sum = 0,
|
sum = 0,
|
||||||
@@ -388,13 +394,13 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return patchesFound;
|
return patchesFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds patches which are connected and share the same orientation
|
* finds patches which are connected and share the same orientation
|
||||||
* @param {Object} patchesFound
|
* @param {Object} patchesFound
|
||||||
*/
|
*/
|
||||||
function rasterizeAngularSimilarity(patchesFound) {
|
function rasterizeAngularSimilarity(patchesFound) {
|
||||||
var label = 0,
|
var label = 0,
|
||||||
threshold = 0.95,
|
threshold = 0.95,
|
||||||
currIdx = 0,
|
currIdx = 0,
|
||||||
@@ -477,9 +483,9 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
export default {
|
||||||
init : function(inputImageWrapper, config) {
|
init : function(inputImageWrapper, config) {
|
||||||
_config = config;
|
_config = config;
|
||||||
_inputImageWrapper = inputImageWrapper;
|
_inputImageWrapper = inputImageWrapper;
|
||||||
@@ -556,6 +562,4 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
width + " )and height (" + height +
|
width + " )and height (" + height +
|
||||||
") must a multiple of " + patchSize.x);
|
") must a multiple of " + patchSize.x);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|
||||||
|
|||||||
+26
-35
@@ -1,17 +1,10 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
function BarcodeReader(config) {
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
|
||||||
function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function BarcodeReader(config) {
|
|
||||||
this._row = [];
|
this._row = [];
|
||||||
this.config = config || {};
|
this.config = config || {};
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
BarcodeReader.prototype._nextUnset = function(line, start) {
|
BarcodeReader.prototype._nextUnset = function(line, start) {
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
if (start === undefined) {
|
if (start === undefined) {
|
||||||
@@ -23,9 +16,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return line.length;
|
return line.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
BarcodeReader.prototype._matchPattern = function(counter, code) {
|
BarcodeReader.prototype._matchPattern = function(counter, code) {
|
||||||
var i,
|
var i,
|
||||||
error = 0,
|
error = 0,
|
||||||
singleError = 0,
|
singleError = 0,
|
||||||
@@ -40,9 +33,9 @@ define(
|
|||||||
error += singleError;
|
error += singleError;
|
||||||
}
|
}
|
||||||
return error/modulo;
|
return error/modulo;
|
||||||
};
|
};
|
||||||
|
|
||||||
BarcodeReader.prototype._nextSet = function(line, offset) {
|
BarcodeReader.prototype._nextSet = function(line, offset) {
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
offset = offset || 0;
|
offset = offset || 0;
|
||||||
@@ -52,9 +45,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return line.length;
|
return line.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
BarcodeReader.prototype._normalize = function(counter, modulo) {
|
BarcodeReader.prototype._normalize = function(counter, modulo) {
|
||||||
var i,
|
var i,
|
||||||
self = this,
|
self = this,
|
||||||
sum = 0,
|
sum = 0,
|
||||||
@@ -87,9 +80,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return normalized;
|
return normalized;
|
||||||
};
|
};
|
||||||
|
|
||||||
BarcodeReader.prototype._matchTrace = function(cmpCounter, epsilon) {
|
BarcodeReader.prototype._matchTrace = function(cmpCounter, epsilon) {
|
||||||
var counter = [],
|
var counter = [],
|
||||||
i,
|
i,
|
||||||
self = this,
|
self = this,
|
||||||
@@ -148,9 +141,9 @@ define(
|
|||||||
bestMatch.end = self._row.length - 1;
|
bestMatch.end = self._row.length - 1;
|
||||||
bestMatch.counter = counter;
|
bestMatch.counter = counter;
|
||||||
return bestMatch;
|
return bestMatch;
|
||||||
};
|
};
|
||||||
|
|
||||||
BarcodeReader.prototype.decodePattern = function(pattern) {
|
BarcodeReader.prototype.decodePattern = function(pattern) {
|
||||||
var self = this,
|
var self = this,
|
||||||
result;
|
result;
|
||||||
|
|
||||||
@@ -171,9 +164,9 @@ define(
|
|||||||
result.format = self.FORMAT;
|
result.format = self.FORMAT;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
BarcodeReader.prototype._matchRange = function(start, end, value) {
|
BarcodeReader.prototype._matchRange = function(start, end, value) {
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
start = start < 0 ? 0 : start;
|
start = start < 0 ? 0 : start;
|
||||||
@@ -183,9 +176,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
BarcodeReader.prototype._fillCounters = function(offset, end, isWhite) {
|
BarcodeReader.prototype._fillCounters = function(offset, end, isWhite) {
|
||||||
var self = this,
|
var self = this,
|
||||||
counterPos = 0,
|
counterPos = 0,
|
||||||
i,
|
i,
|
||||||
@@ -206,26 +199,24 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return counters;
|
return counters;
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.defineProperty(BarcodeReader.prototype, "FORMAT", {
|
Object.defineProperty(BarcodeReader.prototype, "FORMAT", {
|
||||||
value: 'unknown',
|
value: 'unknown',
|
||||||
writeable: false
|
writeable: false
|
||||||
});
|
});
|
||||||
|
|
||||||
BarcodeReader.DIRECTION = {
|
BarcodeReader.DIRECTION = {
|
||||||
FORWARD : 1,
|
FORWARD : 1,
|
||||||
REVERSE : -1
|
REVERSE : -1
|
||||||
};
|
};
|
||||||
|
|
||||||
BarcodeReader.Exception = {
|
BarcodeReader.Exception = {
|
||||||
StartNotFoundException : "Start-Info was not found!",
|
StartNotFoundException : "Start-Info was not found!",
|
||||||
CodeNotFoundException : "Code could not be found!",
|
CodeNotFoundException : "Code could not be found!",
|
||||||
PatternNotFoundException : "Pattern could not be found!"
|
PatternNotFoundException : "Pattern could not be found!"
|
||||||
};
|
};
|
||||||
|
|
||||||
BarcodeReader.CONFIG_KEYS = {};
|
BarcodeReader.CONFIG_KEYS = {};
|
||||||
|
|
||||||
return (BarcodeReader);
|
export default BarcodeReader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+17
-20
@@ -1,17 +1,15 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import CVUtils from './cv_utils';
|
||||||
/* global define */
|
import ImageWrapper from './image_wrapper';
|
||||||
|
|
||||||
define(["cv_utils", "image_wrapper"], function(CVUtils, ImageWrapper) {
|
var Bresenham = {};
|
||||||
"use strict";
|
|
||||||
var Bresenham = {};
|
|
||||||
|
|
||||||
var Slope = {
|
var Slope = {
|
||||||
DIR : {
|
DIR : {
|
||||||
UP : 1,
|
UP : 1,
|
||||||
DOWN : -1
|
DOWN : -1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Scans a line of the given image from point p1 to p2 and returns a result object containing
|
* Scans a line of the given image from point p1 to p2 and returns a result object containing
|
||||||
* gray-scale values (0-255) of the underlying pixels in addition to the min
|
* gray-scale values (0-255) of the underlying pixels in addition to the min
|
||||||
* and max values.
|
* and max values.
|
||||||
@@ -20,7 +18,7 @@ define(["cv_utils", "image_wrapper"], function(CVUtils, ImageWrapper) {
|
|||||||
* @param {Object} p2 The end point {x,y}
|
* @param {Object} p2 The end point {x,y}
|
||||||
* @returns {line, min, max}
|
* @returns {line, min, max}
|
||||||
*/
|
*/
|
||||||
Bresenham.getBarcodeLine = function(imageWrapper, p1, p2) {
|
Bresenham.getBarcodeLine = function(imageWrapper, p1, p2) {
|
||||||
var x0 = p1.x | 0,
|
var x0 = p1.x | 0,
|
||||||
y0 = p1.y | 0,
|
y0 = p1.y | 0,
|
||||||
x1 = p2.x | 0,
|
x1 = p2.x | 0,
|
||||||
@@ -90,9 +88,9 @@ define(["cv_utils", "image_wrapper"], function(CVUtils, ImageWrapper) {
|
|||||||
min : min,
|
min : min,
|
||||||
max : max
|
max : max
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
Bresenham.toOtsuBinaryLine = function(result) {
|
Bresenham.toOtsuBinaryLine = function(result) {
|
||||||
var line = result.line,
|
var line = result.line,
|
||||||
image = new ImageWrapper({x: line.length - 1, y: 1}, line),
|
image = new ImageWrapper({x: line.length - 1, y: 1}, line),
|
||||||
threshold = CVUtils.determineOtsuThreshold(image, 5);
|
threshold = CVUtils.determineOtsuThreshold(image, 5);
|
||||||
@@ -104,14 +102,14 @@ define(["cv_utils", "image_wrapper"], function(CVUtils, ImageWrapper) {
|
|||||||
line: line,
|
line: line,
|
||||||
threshold: threshold
|
threshold: threshold
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the result from getBarcodeLine into a binary representation
|
* Converts the result from getBarcodeLine into a binary representation
|
||||||
* also considering the frequency and slope of the signal for more robust results
|
* also considering the frequency and slope of the signal for more robust results
|
||||||
* @param {Object} result {line, min, max}
|
* @param {Object} result {line, min, max}
|
||||||
*/
|
*/
|
||||||
Bresenham.toBinaryLine = function(result) {
|
Bresenham.toBinaryLine = function(result) {
|
||||||
|
|
||||||
var min = result.min,
|
var min = result.min,
|
||||||
max = result.max,
|
max = result.max,
|
||||||
@@ -178,12 +176,12 @@ define(["cv_utils", "image_wrapper"], function(CVUtils, ImageWrapper) {
|
|||||||
line : line,
|
line : line,
|
||||||
threshold : threshold
|
threshold : threshold
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for development only
|
* Used for development only
|
||||||
*/
|
*/
|
||||||
Bresenham.debug = {
|
Bresenham.debug = {
|
||||||
printFrequency: function(line, canvas) {
|
printFrequency: function(line, canvas) {
|
||||||
var i,
|
var i,
|
||||||
ctx = canvas.getContext("2d");
|
ctx = canvas.getContext("2d");
|
||||||
@@ -211,7 +209,6 @@ define(["cv_utils", "image_wrapper"], function(CVUtils, ImageWrapper) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Bresenham);
|
export default Bresenham;
|
||||||
});
|
|
||||||
|
|||||||
+19
-23
@@ -1,18 +1,15 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
const merge = require('lodash/object/merge');
|
||||||
/* global define, MediaStreamTrack */
|
|
||||||
|
|
||||||
define(["html_utils"], function(HtmlUtils) {
|
var streamRef,
|
||||||
"use strict";
|
|
||||||
var streamRef,
|
|
||||||
loadedDataHandler;
|
loadedDataHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps browser-specific getUserMedia
|
* Wraps browser-specific getUserMedia
|
||||||
* @param {Object} constraints
|
* @param {Object} constraints
|
||||||
* @param {Object} success Callback
|
* @param {Object} success Callback
|
||||||
* @param {Object} failure Callback
|
* @param {Object} failure Callback
|
||||||
*/
|
*/
|
||||||
function getUserMedia(constraints, success, failure) {
|
function getUserMedia(constraints, success, failure) {
|
||||||
if (typeof navigator.getUserMedia !== 'undefined') {
|
if (typeof navigator.getUserMedia !== 'undefined') {
|
||||||
navigator.getUserMedia(constraints, function (stream) {
|
navigator.getUserMedia(constraints, function (stream) {
|
||||||
streamRef = stream;
|
streamRef = stream;
|
||||||
@@ -22,9 +19,9 @@ define(["html_utils"], function(HtmlUtils) {
|
|||||||
} else {
|
} else {
|
||||||
failure(new TypeError("getUserMedia not available"));
|
failure(new TypeError("getUserMedia not available"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadedData(video, callback) {
|
function loadedData(video, callback) {
|
||||||
var attempts = 10;
|
var attempts = 10;
|
||||||
|
|
||||||
function checkVideo() {
|
function checkVideo() {
|
||||||
@@ -41,16 +38,16 @@ define(["html_utils"], function(HtmlUtils) {
|
|||||||
attempts--;
|
attempts--;
|
||||||
}
|
}
|
||||||
checkVideo();
|
checkVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to attach the camera-stream to a given video-element
|
* Tries to attach the camera-stream to a given video-element
|
||||||
* and calls the callback function when the content is ready
|
* and calls the callback function when the content is ready
|
||||||
* @param {Object} constraints
|
* @param {Object} constraints
|
||||||
* @param {Object} video
|
* @param {Object} video
|
||||||
* @param {Object} callback
|
* @param {Object} callback
|
||||||
*/
|
*/
|
||||||
function initCamera(constraints, video, callback) {
|
function initCamera(constraints, video, callback) {
|
||||||
getUserMedia(constraints, function(src) {
|
getUserMedia(constraints, function(src) {
|
||||||
video.src = src;
|
video.src = src;
|
||||||
if (loadedDataHandler) {
|
if (loadedDataHandler) {
|
||||||
@@ -62,20 +59,20 @@ define(["html_utils"], function(HtmlUtils) {
|
|||||||
}, function(e) {
|
}, function(e) {
|
||||||
callback(e);
|
callback(e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalizes the incoming constraints to satisfy the current browser
|
* Normalizes the incoming constraints to satisfy the current browser
|
||||||
* @param config
|
* @param config
|
||||||
* @param cb Callback which is called whenever constraints are created
|
* @param cb Callback which is called whenever constraints are created
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
function normalizeConstraints(config, cb) {
|
function normalizeConstraints(config, cb) {
|
||||||
var constraints = {
|
var constraints = {
|
||||||
audio: false,
|
audio: false,
|
||||||
video: true
|
video: true
|
||||||
},
|
},
|
||||||
videoConstraints = HtmlUtils.mergeObjects({
|
videoConstraints = merge({
|
||||||
width: 640,
|
width: 640,
|
||||||
height: 480,
|
height: 480,
|
||||||
minAspectRatio: 0,
|
minAspectRatio: 0,
|
||||||
@@ -114,21 +111,21 @@ define(["html_utils"], function(HtmlUtils) {
|
|||||||
};
|
};
|
||||||
return cb(constraints);
|
return cb(constraints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests the back-facing camera of the user. The callback is called
|
* Requests the back-facing camera of the user. The callback is called
|
||||||
* whenever the stream is ready to be consumed, or if an error occures.
|
* whenever the stream is ready to be consumed, or if an error occures.
|
||||||
* @param {Object} video
|
* @param {Object} video
|
||||||
* @param {Object} callback
|
* @param {Object} callback
|
||||||
*/
|
*/
|
||||||
function request(video, videoConstraints, callback) {
|
function request(video, videoConstraints, callback) {
|
||||||
normalizeConstraints(videoConstraints, function(constraints) {
|
normalizeConstraints(videoConstraints, function(constraints) {
|
||||||
initCamera(constraints, video, callback);
|
initCamera(constraints, video, callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
export default {
|
||||||
request : function(video, constraints, callback) {
|
request : function(video, constraints, callback) {
|
||||||
request(video, constraints, callback);
|
request(video, constraints, callback);
|
||||||
},
|
},
|
||||||
@@ -139,5 +136,4 @@ define(["html_utils"], function(HtmlUtils) {
|
|||||||
}
|
}
|
||||||
streamRef = null;
|
streamRef = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|||||||
+3
-12
@@ -1,14 +1,8 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import {vec2} from 'gl-matrix';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(["gl-matrix"], function(glMatrix) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var vec2 = glMatrix.vec2;
|
|
||||||
/**
|
/**
|
||||||
* Creates a cluster for grouping similar orientations of datapoints
|
* Creates a cluster for grouping similar orientations of datapoints
|
||||||
*/
|
*/
|
||||||
var Cluster = {
|
export default {
|
||||||
create : function(point, threshold) {
|
create : function(point, threshold) {
|
||||||
var points = [], center = {
|
var points = [], center = {
|
||||||
rad : 0,
|
rad : 0,
|
||||||
@@ -66,7 +60,4 @@ define(["gl-matrix"], function(glMatrix) {
|
|||||||
id : id
|
id : id
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Cluster);
|
|
||||||
});
|
|
||||||
|
|||||||
+32
-42
@@ -1,19 +1,11 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import BarcodeReader from './barcode_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
function CodabarReader() {
|
||||||
[
|
|
||||||
"./barcode_reader"
|
|
||||||
],
|
|
||||||
function(BarcodeReader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function CodabarReader() {
|
|
||||||
BarcodeReader.call(this);
|
BarcodeReader.call(this);
|
||||||
this._counters = [];
|
this._counters = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
ALPHABETH_STRING: {value: "0123456789-$:/.+ABCD"},
|
ALPHABETH_STRING: {value: "0123456789-$:/.+ABCD"},
|
||||||
ALPHABET: {value: [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 36, 58, 47, 46, 43, 65, 66, 67, 68]},
|
ALPHABET: {value: [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 36, 58, 47, 46, 43, 65, 66, 67, 68]},
|
||||||
CHARACTER_ENCODINGS: {value: [0x003, 0x006, 0x009, 0x060, 0x012, 0x042, 0x021, 0x024, 0x030, 0x048, 0x00c, 0x018, 0x045, 0x051, 0x054, 0x015, 0x01A, 0x029, 0x00B, 0x00E]},
|
CHARACTER_ENCODINGS: {value: [0x003, 0x006, 0x009, 0x060, 0x012, 0x042, 0x021, 0x024, 0x030, 0x048, 0x00c, 0x018, 0x045, 0x051, 0x054, 0x015, 0x01A, 0x029, 0x00B, 0x00E]},
|
||||||
@@ -22,12 +14,12 @@ define(
|
|||||||
MAX_ACCEPTABLE: {value: 2.0},
|
MAX_ACCEPTABLE: {value: 2.0},
|
||||||
PADDING: {value: 1.5},
|
PADDING: {value: 1.5},
|
||||||
FORMAT: {value: "codabar", writeable: false}
|
FORMAT: {value: "codabar", writeable: false}
|
||||||
};
|
};
|
||||||
|
|
||||||
CodabarReader.prototype = Object.create(BarcodeReader.prototype, properties);
|
CodabarReader.prototype = Object.create(BarcodeReader.prototype, properties);
|
||||||
CodabarReader.prototype.constructor = CodabarReader;
|
CodabarReader.prototype.constructor = CodabarReader;
|
||||||
|
|
||||||
CodabarReader.prototype._decode = function() {
|
CodabarReader.prototype._decode = function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
result = [],
|
result = [],
|
||||||
start,
|
start,
|
||||||
@@ -83,18 +75,18 @@ define(
|
|||||||
startInfo : start,
|
startInfo : start,
|
||||||
decodedCodes : result
|
decodedCodes : result
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
CodabarReader.prototype._verifyWhitespace = function(startCounter, endCounter) {
|
CodabarReader.prototype._verifyWhitespace = function(startCounter, endCounter) {
|
||||||
if ((startCounter - 1 <= 0) || this._counters[startCounter-1] >= (this._calculatePatternLength(startCounter) / 2.0)) {
|
if ((startCounter - 1 <= 0) || this._counters[startCounter-1] >= (this._calculatePatternLength(startCounter) / 2.0)) {
|
||||||
if ((endCounter + 8 >= this._counters.length) || this._counters[endCounter+7] >= (this._calculatePatternLength(endCounter) / 2.0)) {
|
if ((endCounter + 8 >= this._counters.length) || this._counters[endCounter+7] >= (this._calculatePatternLength(endCounter) / 2.0)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
CodabarReader.prototype._calculatePatternLength = function(offset) {
|
CodabarReader.prototype._calculatePatternLength = function(offset) {
|
||||||
var i,
|
var i,
|
||||||
sum = 0;
|
sum = 0;
|
||||||
|
|
||||||
@@ -103,9 +95,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
};
|
};
|
||||||
|
|
||||||
CodabarReader.prototype._thresholdResultPattern = function(result, startCounter){
|
CodabarReader.prototype._thresholdResultPattern = function(result, startCounter){
|
||||||
var self = this,
|
var self = this,
|
||||||
categorization = {
|
categorization = {
|
||||||
space: {
|
space: {
|
||||||
@@ -144,9 +136,9 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
return categorization;
|
return categorization;
|
||||||
};
|
};
|
||||||
|
|
||||||
CodabarReader.prototype._charToPattern = function(char) {
|
CodabarReader.prototype._charToPattern = function(char) {
|
||||||
var self = this,
|
var self = this,
|
||||||
charCode = char.charCodeAt(0),
|
charCode = char.charCodeAt(0),
|
||||||
i;
|
i;
|
||||||
@@ -157,9 +149,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0x0;
|
return 0x0;
|
||||||
};
|
};
|
||||||
|
|
||||||
CodabarReader.prototype._validateResult = function(result, startCounter) {
|
CodabarReader.prototype._validateResult = function(result, startCounter) {
|
||||||
var self = this,
|
var self = this,
|
||||||
thresholds = self._thresholdResultPattern(result, startCounter),
|
thresholds = self._thresholdResultPattern(result, startCounter),
|
||||||
i,
|
i,
|
||||||
@@ -184,9 +176,9 @@ define(
|
|||||||
pos += 8;
|
pos += 8;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
CodabarReader.prototype._patternToChar = function(pattern) {
|
CodabarReader.prototype._patternToChar = function(pattern) {
|
||||||
var i,
|
var i,
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
@@ -196,9 +188,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
CodabarReader.prototype._computeAlternatingThreshold = function(offset, end) {
|
CodabarReader.prototype._computeAlternatingThreshold = function(offset, end) {
|
||||||
var i,
|
var i,
|
||||||
min = Number.MAX_VALUE,
|
min = Number.MAX_VALUE,
|
||||||
max = 0,
|
max = 0,
|
||||||
@@ -215,9 +207,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ((min + max) / 2.0) | 0;
|
return ((min + max) / 2.0) | 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
CodabarReader.prototype._toPattern = function(offset) {
|
CodabarReader.prototype._toPattern = function(offset) {
|
||||||
var numCounters = 7,
|
var numCounters = 7,
|
||||||
end = offset + numCounters,
|
end = offset + numCounters,
|
||||||
barThreshold,
|
barThreshold,
|
||||||
@@ -243,9 +235,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return pattern;
|
return pattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
CodabarReader.prototype._isStartEnd = function(pattern) {
|
CodabarReader.prototype._isStartEnd = function(pattern) {
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
for (i = 0; i < this.START_END.length; i++) {
|
for (i = 0; i < this.START_END.length; i++) {
|
||||||
@@ -254,9 +246,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
CodabarReader.prototype._sumCounters = function(start, end) {
|
CodabarReader.prototype._sumCounters = function(start, end) {
|
||||||
var i,
|
var i,
|
||||||
sum = 0;
|
sum = 0;
|
||||||
|
|
||||||
@@ -264,9 +256,9 @@ define(
|
|||||||
sum += this._counters[i];
|
sum += this._counters[i];
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
};
|
};
|
||||||
|
|
||||||
CodabarReader.prototype._findStart = function() {
|
CodabarReader.prototype._findStart = function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
i,
|
i,
|
||||||
pattern,
|
pattern,
|
||||||
@@ -287,8 +279,6 @@ define(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (CodabarReader);
|
export default CodabarReader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+16
-26
@@ -1,18 +1,10 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import BarcodeReader from './barcode_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
function Code128Reader() {
|
||||||
[
|
|
||||||
"./barcode_reader"
|
|
||||||
],
|
|
||||||
function(BarcodeReader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function Code128Reader() {
|
|
||||||
BarcodeReader.call(this);
|
BarcodeReader.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
CODE_SHIFT : {value: 98},
|
CODE_SHIFT : {value: 98},
|
||||||
CODE_C : {value: 99},
|
CODE_C : {value: 99},
|
||||||
CODE_B : {value: 100},
|
CODE_B : {value: 100},
|
||||||
@@ -134,12 +126,12 @@ define(
|
|||||||
SINGLE_CODE_ERROR: {value: 1},
|
SINGLE_CODE_ERROR: {value: 1},
|
||||||
AVG_CODE_ERROR: {value: 0.5},
|
AVG_CODE_ERROR: {value: 0.5},
|
||||||
FORMAT: {value: "code_128", writeable: false}
|
FORMAT: {value: "code_128", writeable: false}
|
||||||
};
|
};
|
||||||
|
|
||||||
Code128Reader.prototype = Object.create(BarcodeReader.prototype, properties);
|
Code128Reader.prototype = Object.create(BarcodeReader.prototype, properties);
|
||||||
Code128Reader.prototype.constructor = Code128Reader;
|
Code128Reader.prototype.constructor = Code128Reader;
|
||||||
|
|
||||||
Code128Reader.prototype._decodeCode = function(start) {
|
Code128Reader.prototype._decodeCode = function(start) {
|
||||||
var counter = [0, 0, 0, 0, 0, 0],
|
var counter = [0, 0, 0, 0, 0, 0],
|
||||||
i,
|
i,
|
||||||
self = this,
|
self = this,
|
||||||
@@ -181,9 +173,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
Code128Reader.prototype._findStart = function() {
|
Code128Reader.prototype._findStart = function() {
|
||||||
var counter = [0, 0, 0, 0, 0, 0],
|
var counter = [0, 0, 0, 0, 0, 0],
|
||||||
i,
|
i,
|
||||||
self = this,
|
self = this,
|
||||||
@@ -241,9 +233,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
Code128Reader.prototype._decode = function() {
|
Code128Reader.prototype._decode = function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
startInfo = self._findStart(),
|
startInfo = self._findStart(),
|
||||||
code = null,
|
code = null,
|
||||||
@@ -402,10 +394,10 @@ define(
|
|||||||
decodedCodes : decodedCodes,
|
decodedCodes : decodedCodes,
|
||||||
endInfo : code
|
endInfo : code
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
BarcodeReader.prototype._verifyTrailingWhitespace = function(endInfo) {
|
BarcodeReader.prototype._verifyTrailingWhitespace = function(endInfo) {
|
||||||
var self = this,
|
var self = this,
|
||||||
trailingWhitespaceEnd;
|
trailingWhitespaceEnd;
|
||||||
|
|
||||||
@@ -416,8 +408,6 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Code128Reader);
|
export default Code128Reader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+23
-33
@@ -1,30 +1,22 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import BarcodeReader from './barcode_reader';
|
||||||
/* global define */
|
import ArrayHelper from './array_helper';
|
||||||
|
|
||||||
define(
|
function Code39Reader() {
|
||||||
[
|
|
||||||
"./barcode_reader",
|
|
||||||
"./array_helper"
|
|
||||||
],
|
|
||||||
function(BarcodeReader, ArrayHelper) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function Code39Reader() {
|
|
||||||
BarcodeReader.call(this);
|
BarcodeReader.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
ALPHABETH_STRING: {value: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%"},
|
ALPHABETH_STRING: {value: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%"},
|
||||||
ALPHABET: {value: [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 45, 46, 32, 42, 36, 47, 43, 37]},
|
ALPHABET: {value: [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 45, 46, 32, 42, 36, 47, 43, 37]},
|
||||||
CHARACTER_ENCODINGS: {value: [0x034, 0x121, 0x061, 0x160, 0x031, 0x130, 0x070, 0x025, 0x124, 0x064, 0x109, 0x049, 0x148, 0x019, 0x118, 0x058, 0x00D, 0x10C, 0x04C, 0x01C, 0x103, 0x043, 0x142, 0x013, 0x112, 0x052, 0x007, 0x106, 0x046, 0x016, 0x181, 0x0C1, 0x1C0, 0x091, 0x190, 0x0D0, 0x085, 0x184, 0x0C4, 0x094, 0x0A8, 0x0A2, 0x08A, 0x02A]},
|
CHARACTER_ENCODINGS: {value: [0x034, 0x121, 0x061, 0x160, 0x031, 0x130, 0x070, 0x025, 0x124, 0x064, 0x109, 0x049, 0x148, 0x019, 0x118, 0x058, 0x00D, 0x10C, 0x04C, 0x01C, 0x103, 0x043, 0x142, 0x013, 0x112, 0x052, 0x007, 0x106, 0x046, 0x016, 0x181, 0x0C1, 0x1C0, 0x091, 0x190, 0x0D0, 0x085, 0x184, 0x0C4, 0x094, 0x0A8, 0x0A2, 0x08A, 0x02A]},
|
||||||
ASTERISK: {value: 0x094},
|
ASTERISK: {value: 0x094},
|
||||||
FORMAT: {value: "code_39", writeable: false}
|
FORMAT: {value: "code_39", writeable: false}
|
||||||
};
|
};
|
||||||
|
|
||||||
Code39Reader.prototype = Object.create(BarcodeReader.prototype, properties);
|
Code39Reader.prototype = Object.create(BarcodeReader.prototype, properties);
|
||||||
Code39Reader.prototype.constructor = Code39Reader;
|
Code39Reader.prototype.constructor = Code39Reader;
|
||||||
|
|
||||||
Code39Reader.prototype._toCounters = function(start, counter) {
|
Code39Reader.prototype._toCounters = function(start, counter) {
|
||||||
var self = this,
|
var self = this,
|
||||||
numCounters = counter.length,
|
numCounters = counter.length,
|
||||||
end = self._row.length,
|
end = self._row.length,
|
||||||
@@ -49,9 +41,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return counter;
|
return counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
Code39Reader.prototype._decode = function() {
|
Code39Reader.prototype._decode = function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
counters = [0,0,0,0,0,0,0,0,0],
|
counters = [0,0,0,0,0,0,0,0,0],
|
||||||
result = [],
|
result = [],
|
||||||
@@ -98,9 +90,9 @@ define(
|
|||||||
startInfo : start,
|
startInfo : start,
|
||||||
decodedCodes : result
|
decodedCodes : result
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
Code39Reader.prototype._verifyTrailingWhitespace = function(lastStart, nextStart, counters) {
|
Code39Reader.prototype._verifyTrailingWhitespace = function(lastStart, nextStart, counters) {
|
||||||
var trailingWhitespaceEnd,
|
var trailingWhitespaceEnd,
|
||||||
patternSize = ArrayHelper.sum(counters);
|
patternSize = ArrayHelper.sum(counters);
|
||||||
|
|
||||||
@@ -109,9 +101,9 @@ define(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
Code39Reader.prototype._patternToChar = function(pattern) {
|
Code39Reader.prototype._patternToChar = function(pattern) {
|
||||||
var i,
|
var i,
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
@@ -120,9 +112,9 @@ define(
|
|||||||
return String.fromCharCode(self.ALPHABET[i]);
|
return String.fromCharCode(self.ALPHABET[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Code39Reader.prototype._findNextWidth = function(counters, current) {
|
Code39Reader.prototype._findNextWidth = function(counters, current) {
|
||||||
var i,
|
var i,
|
||||||
minWidth = Number.MAX_VALUE;
|
minWidth = Number.MAX_VALUE;
|
||||||
|
|
||||||
@@ -133,9 +125,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return minWidth;
|
return minWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
Code39Reader.prototype._toPattern = function(counters) {
|
Code39Reader.prototype._toPattern = function(counters) {
|
||||||
var numCounters = counters.length,
|
var numCounters = counters.length,
|
||||||
maxNarrowWidth = 0,
|
maxNarrowWidth = 0,
|
||||||
numWideBars = numCounters,
|
numWideBars = numCounters,
|
||||||
@@ -169,9 +161,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
Code39Reader.prototype._findStart = function() {
|
Code39Reader.prototype._findStart = function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
offset = self._nextSet(self._row),
|
offset = self._nextSet(self._row),
|
||||||
patternStart = offset,
|
patternStart = offset,
|
||||||
@@ -214,8 +206,6 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Code39Reader);
|
export default Code39Reader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+14
-24
@@ -1,28 +1,20 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import Code39Reader from './code_39_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
function Code39VINReader() {
|
||||||
[
|
|
||||||
"./code_39_reader"
|
|
||||||
],
|
|
||||||
function(Code39Reader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function Code39VINReader() {
|
|
||||||
Code39Reader.call(this);
|
Code39Reader.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
var patterns = {
|
var patterns = {
|
||||||
IOQ: /[IOQ]/g,
|
IOQ: /[IOQ]/g,
|
||||||
AZ09: /[A-Z0-9]{17}/
|
AZ09: /[A-Z0-9]{17}/
|
||||||
};
|
};
|
||||||
|
|
||||||
Code39VINReader.prototype = Object.create(Code39Reader.prototype);
|
Code39VINReader.prototype = Object.create(Code39Reader.prototype);
|
||||||
Code39VINReader.prototype.constructor = Code39VINReader;
|
Code39VINReader.prototype.constructor = Code39VINReader;
|
||||||
|
|
||||||
// Cribbed from:
|
// Cribbed from:
|
||||||
// https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/client/result/VINResultParser.java
|
// https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/client/result/VINResultParser.java
|
||||||
Code39VINReader.prototype._decode = function() {
|
Code39VINReader.prototype._decode = function() {
|
||||||
var result = Code39Reader.prototype._decode.apply(this);
|
var result = Code39Reader.prototype._decode.apply(this);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return null;
|
return null;
|
||||||
@@ -47,13 +39,11 @@ define(
|
|||||||
|
|
||||||
result.code = code;
|
result.code = code;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
Code39VINReader.prototype._checkChecksum = function(code) {
|
Code39VINReader.prototype._checkChecksum = function(code) {
|
||||||
// TODO
|
// TODO
|
||||||
return !!code;
|
return !!code;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Code39VINReader);
|
export default Code39VINReader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+5
-12
@@ -1,10 +1,6 @@
|
|||||||
/**
|
export default {
|
||||||
* The basic configuration
|
inputStream: {
|
||||||
*/
|
name: "Live",
|
||||||
|
|
||||||
define(function(){
|
|
||||||
var config = {
|
|
||||||
inputStream: { name: "Live",
|
|
||||||
type: "LiveStream",
|
type: "LiveStream",
|
||||||
constraints: {
|
constraints: {
|
||||||
width: 640,
|
width: 640,
|
||||||
@@ -29,7 +25,7 @@ define(function(){
|
|||||||
visual: {
|
visual: {
|
||||||
show: true
|
show: true
|
||||||
},
|
},
|
||||||
decoder:{
|
decoder: {
|
||||||
drawBoundingBox: false,
|
drawBoundingBox: false,
|
||||||
showFrequency: false,
|
showFrequency: false,
|
||||||
drawScanline: false,
|
drawScanline: false,
|
||||||
@@ -54,7 +50,4 @@ define(function(){
|
|||||||
showBB: false
|
showBB: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return config;
|
|
||||||
});
|
|
||||||
|
|||||||
+71
-87
@@ -1,29 +1,15 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import Cluster2 from './cluster';
|
||||||
/* global define */
|
import ArrayHelper from './array_helper';
|
||||||
|
import {vec2, vec3} from 'gl-matrix';
|
||||||
|
|
||||||
define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper, glMatrix) {
|
var CVUtils = {};
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
/*
|
|
||||||
* cv_utils.js
|
|
||||||
* Collection of CV functions and libraries
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Namespace for various CV alorithms
|
|
||||||
* @class Represents a collection of useful CV algorithms/functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
var CVUtils = {},
|
|
||||||
vec2 = glMatrix.vec2,
|
|
||||||
vec3 = glMatrix.vec3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param x x-coordinate
|
* @param x x-coordinate
|
||||||
* @param y y-coordinate
|
* @param y y-coordinate
|
||||||
* @return ImageReference {x,y} Coordinate
|
* @return ImageReference {x,y} Coordinate
|
||||||
*/
|
*/
|
||||||
CVUtils.imageRef = function(x, y) {
|
CVUtils.imageRef = function(x, y) {
|
||||||
var that = {
|
var that = {
|
||||||
x : x,
|
x : x,
|
||||||
y : y,
|
y : y,
|
||||||
@@ -40,13 +26,13 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes an integral image of a given grayscale image.
|
* Computes an integral image of a given grayscale image.
|
||||||
* @param imageDataContainer {ImageDataContainer} the image to be integrated
|
* @param imageDataContainer {ImageDataContainer} the image to be integrated
|
||||||
*/
|
*/
|
||||||
CVUtils.computeIntegralImage2 = function(imageWrapper, integralWrapper) {
|
CVUtils.computeIntegralImage2 = function(imageWrapper, integralWrapper) {
|
||||||
var imageData = imageWrapper.data;
|
var imageData = imageWrapper.data;
|
||||||
var width = imageWrapper.size.x;
|
var width = imageWrapper.size.x;
|
||||||
var height = imageWrapper.size.y;
|
var height = imageWrapper.size.y;
|
||||||
@@ -86,9 +72,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
posD++;
|
posD++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.computeIntegralImage = function(imageWrapper, integralWrapper) {
|
CVUtils.computeIntegralImage = function(imageWrapper, integralWrapper) {
|
||||||
var imageData = imageWrapper.data;
|
var imageData = imageWrapper.data;
|
||||||
var width = imageWrapper.size.x;
|
var width = imageWrapper.size.x;
|
||||||
var height = imageWrapper.size.y;
|
var height = imageWrapper.size.y;
|
||||||
@@ -108,9 +94,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
integralImageData[((v) * width) + u] = sum + integralImageData[(v - 1) * width + u];
|
integralImageData[((v) * width) + u] = sum + integralImageData[(v - 1) * width + u];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.thresholdImage = function(imageWrapper, threshold, targetWrapper) {
|
CVUtils.thresholdImage = function(imageWrapper, threshold, targetWrapper) {
|
||||||
if (!targetWrapper) {
|
if (!targetWrapper) {
|
||||||
targetWrapper = imageWrapper;
|
targetWrapper = imageWrapper;
|
||||||
}
|
}
|
||||||
@@ -119,9 +105,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
while (length--) {
|
while (length--) {
|
||||||
targetData[length] = imageData[length] < threshold ? 1 : 0;
|
targetData[length] = imageData[length] < threshold ? 1 : 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.computeHistogram = function(imageWrapper, bitsPerPixel) {
|
CVUtils.computeHistogram = function(imageWrapper, bitsPerPixel) {
|
||||||
if (!bitsPerPixel) {
|
if (!bitsPerPixel) {
|
||||||
bitsPerPixel = 8;
|
bitsPerPixel = 8;
|
||||||
}
|
}
|
||||||
@@ -135,9 +121,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
hist[imageData[length] >> bitShift]++;
|
hist[imageData[length] >> bitShift]++;
|
||||||
}
|
}
|
||||||
return hist;
|
return hist;
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.sharpenLine = function(line) {
|
CVUtils.sharpenLine = function(line) {
|
||||||
var i,
|
var i,
|
||||||
length = line.length,
|
length = line.length,
|
||||||
left = line[0],
|
left = line[0],
|
||||||
@@ -152,9 +138,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
center = right;
|
center = right;
|
||||||
}
|
}
|
||||||
return line;
|
return line;
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.determineOtsuThreshold = function(imageWrapper, bitsPerPixel) {
|
CVUtils.determineOtsuThreshold = function(imageWrapper, bitsPerPixel) {
|
||||||
if (!bitsPerPixel) {
|
if (!bitsPerPixel) {
|
||||||
bitsPerPixel = 8;
|
bitsPerPixel = 8;
|
||||||
}
|
}
|
||||||
@@ -202,17 +188,17 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
|
|
||||||
threshold = determineThreshold();
|
threshold = determineThreshold();
|
||||||
return threshold << bitShift;
|
return threshold << bitShift;
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.otsuThreshold = function(imageWrapper, targetWrapper) {
|
CVUtils.otsuThreshold = function(imageWrapper, targetWrapper) {
|
||||||
var threshold = CVUtils.determineOtsuThreshold(imageWrapper);
|
var threshold = CVUtils.determineOtsuThreshold(imageWrapper);
|
||||||
|
|
||||||
CVUtils.thresholdImage(imageWrapper, threshold, targetWrapper);
|
CVUtils.thresholdImage(imageWrapper, threshold, targetWrapper);
|
||||||
return threshold;
|
return threshold;
|
||||||
};
|
};
|
||||||
|
|
||||||
// local thresholding
|
// local thresholding
|
||||||
CVUtils.computeBinaryImage = function(imageWrapper, integralWrapper, targetWrapper) {
|
CVUtils.computeBinaryImage = function(imageWrapper, integralWrapper, targetWrapper) {
|
||||||
CVUtils.computeIntegralImage(imageWrapper, integralWrapper);
|
CVUtils.computeIntegralImage(imageWrapper, integralWrapper);
|
||||||
|
|
||||||
if (!targetWrapper) {
|
if (!targetWrapper) {
|
||||||
@@ -252,9 +238,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
targetData[v * width + u] = imageData[v * width + u] > (avg + 5) ? 0 : 1;
|
targetData[v * width + u] = imageData[v * width + u] > (avg + 5) ? 0 : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.cluster = function(points, threshold, property) {
|
CVUtils.cluster = function(points, threshold, property) {
|
||||||
var i, k, cluster, point, clusters = [];
|
var i, k, cluster, point, clusters = [];
|
||||||
|
|
||||||
if (!property) {
|
if (!property) {
|
||||||
@@ -283,9 +269,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
|
|
||||||
return clusters;
|
return clusters;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.Tracer = {
|
CVUtils.Tracer = {
|
||||||
trace : function(points, vec) {
|
trace : function(points, vec) {
|
||||||
var iteration, maxIterations = 10, top = [], result = [], centerPos = 0, currentPos = 0;
|
var iteration, maxIterations = 10, top = [], result = [], centerPos = 0, currentPos = 0;
|
||||||
|
|
||||||
@@ -352,12 +338,12 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.DILATE = 1;
|
CVUtils.DILATE = 1;
|
||||||
CVUtils.ERODE = 2;
|
CVUtils.ERODE = 2;
|
||||||
|
|
||||||
CVUtils.dilate = function(inImageWrapper, outImageWrapper) {
|
CVUtils.dilate = function(inImageWrapper, outImageWrapper) {
|
||||||
var v, u, inImageData = inImageWrapper.data, outImageData = outImageWrapper.data, height = inImageWrapper.size.y, width = inImageWrapper.size.x, sum, yStart1, yStart2, xStart1, xStart2;
|
var v, u, inImageData = inImageWrapper.data, outImageData = outImageWrapper.data, height = inImageWrapper.size.y, width = inImageWrapper.size.x, sum, yStart1, yStart2, xStart1, xStart2;
|
||||||
|
|
||||||
for ( v = 1; v < height - 1; v++) {
|
for ( v = 1; v < height - 1; v++) {
|
||||||
@@ -373,9 +359,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
outImageData[v * width + u] = sum > 0 ? 1 : 0;
|
outImageData[v * width + u] = sum > 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.erode = function(inImageWrapper, outImageWrapper) {
|
CVUtils.erode = function(inImageWrapper, outImageWrapper) {
|
||||||
var v, u, inImageData = inImageWrapper.data, outImageData = outImageWrapper.data, height = inImageWrapper.size.y, width = inImageWrapper.size.x, sum, yStart1, yStart2, xStart1, xStart2;
|
var v, u, inImageData = inImageWrapper.data, outImageData = outImageWrapper.data, height = inImageWrapper.size.y, width = inImageWrapper.size.x, sum, yStart1, yStart2, xStart1, xStart2;
|
||||||
|
|
||||||
for ( v = 1; v < height - 1; v++) {
|
for ( v = 1; v < height - 1; v++) {
|
||||||
@@ -391,9 +377,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
outImageData[v * width + u] = sum === 5 ? 1 : 0;
|
outImageData[v * width + u] = sum === 5 ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.subtract = function(aImageWrapper, bImageWrapper, resultImageWrapper) {
|
CVUtils.subtract = function(aImageWrapper, bImageWrapper, resultImageWrapper) {
|
||||||
if (!resultImageWrapper) {
|
if (!resultImageWrapper) {
|
||||||
resultImageWrapper = aImageWrapper;
|
resultImageWrapper = aImageWrapper;
|
||||||
}
|
}
|
||||||
@@ -402,9 +388,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
while (length--) {
|
while (length--) {
|
||||||
cImageData[length] = aImageData[length] - bImageData[length];
|
cImageData[length] = aImageData[length] - bImageData[length];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.bitwiseOr = function(aImageWrapper, bImageWrapper, resultImageWrapper) {
|
CVUtils.bitwiseOr = function(aImageWrapper, bImageWrapper, resultImageWrapper) {
|
||||||
if (!resultImageWrapper) {
|
if (!resultImageWrapper) {
|
||||||
resultImageWrapper = aImageWrapper;
|
resultImageWrapper = aImageWrapper;
|
||||||
}
|
}
|
||||||
@@ -413,18 +399,18 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
while (length--) {
|
while (length--) {
|
||||||
cImageData[length] = aImageData[length] || bImageData[length];
|
cImageData[length] = aImageData[length] || bImageData[length];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.countNonZero = function(imageWrapper) {
|
CVUtils.countNonZero = function(imageWrapper) {
|
||||||
var length = imageWrapper.data.length, data = imageWrapper.data, sum = 0;
|
var length = imageWrapper.data.length, data = imageWrapper.data, sum = 0;
|
||||||
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
sum += data[length];
|
sum += data[length];
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.topGeneric = function(list, top, scoreFunc) {
|
CVUtils.topGeneric = function(list, top, scoreFunc) {
|
||||||
var i, minIdx = 0, min = 0, queue = [], score, hit, pos;
|
var i, minIdx = 0, min = 0, queue = [], score, hit, pos;
|
||||||
|
|
||||||
for ( i = 0; i < top; i++) {
|
for ( i = 0; i < top; i++) {
|
||||||
@@ -451,20 +437,20 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return queue;
|
return queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.grayArrayFromImage = function(htmlImage, offsetX, ctx, array) {
|
CVUtils.grayArrayFromImage = function(htmlImage, offsetX, ctx, array) {
|
||||||
ctx.drawImage(htmlImage, offsetX, 0, htmlImage.width, htmlImage.height);
|
ctx.drawImage(htmlImage, offsetX, 0, htmlImage.width, htmlImage.height);
|
||||||
var ctxData = ctx.getImageData(offsetX, 0, htmlImage.width, htmlImage.height).data;
|
var ctxData = ctx.getImageData(offsetX, 0, htmlImage.width, htmlImage.height).data;
|
||||||
CVUtils.computeGray(ctxData, array);
|
CVUtils.computeGray(ctxData, array);
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.grayArrayFromContext = function(ctx, size, offset, array) {
|
CVUtils.grayArrayFromContext = function(ctx, size, offset, array) {
|
||||||
var ctxData = ctx.getImageData(offset.x, offset.y, size.x, size.y).data;
|
var ctxData = ctx.getImageData(offset.x, offset.y, size.x, size.y).data;
|
||||||
CVUtils.computeGray(ctxData, array);
|
CVUtils.computeGray(ctxData, array);
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.grayAndHalfSampleFromCanvasData = function(canvasData, size, outArray) {
|
CVUtils.grayAndHalfSampleFromCanvasData = function(canvasData, size, outArray) {
|
||||||
var topRowIdx = 0;
|
var topRowIdx = 0;
|
||||||
var bottomRowIdx = size.x;
|
var bottomRowIdx = size.x;
|
||||||
var endIdx = Math.floor(canvasData.length / 4);
|
var endIdx = Math.floor(canvasData.length / 4);
|
||||||
@@ -484,9 +470,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
bottomRowIdx = bottomRowIdx + inWidth;
|
bottomRowIdx = bottomRowIdx + inWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.computeGray = function(imageData, outArray, config) {
|
CVUtils.computeGray = function(imageData, outArray, config) {
|
||||||
var l = (imageData.length / 4) | 0,
|
var l = (imageData.length / 4) | 0,
|
||||||
i,
|
i,
|
||||||
singleChannel = config && config.singleChannel === true;
|
singleChannel = config && config.singleChannel === true;
|
||||||
@@ -500,9 +486,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
outArray[i] = Math.floor(0.299 * imageData[i * 4 + 0] + 0.587 * imageData[i * 4 + 1] + 0.114 * imageData[i * 4 + 2]);
|
outArray[i] = Math.floor(0.299 * imageData[i * 4 + 0] + 0.587 * imageData[i * 4 + 1] + 0.114 * imageData[i * 4 + 2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.loadImageArray = function(src, callback, canvas) {
|
CVUtils.loadImageArray = function(src, callback, canvas) {
|
||||||
if (!canvas)
|
if (!canvas)
|
||||||
canvas = document.createElement('canvas');
|
canvas = document.createElement('canvas');
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
@@ -522,13 +508,13 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
}, this);
|
}, this);
|
||||||
};
|
};
|
||||||
img.src = src;
|
img.src = src;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param inImg {ImageWrapper} input image to be sampled
|
* @param inImg {ImageWrapper} input image to be sampled
|
||||||
* @param outImg {ImageWrapper} to be stored in
|
* @param outImg {ImageWrapper} to be stored in
|
||||||
*/
|
*/
|
||||||
CVUtils.halfSample = function(inImgWrapper, outImgWrapper) {
|
CVUtils.halfSample = function(inImgWrapper, outImgWrapper) {
|
||||||
var inImg = inImgWrapper.data;
|
var inImg = inImgWrapper.data;
|
||||||
var inWidth = inImgWrapper.size.x;
|
var inWidth = inImgWrapper.size.x;
|
||||||
var outImg = outImgWrapper.data;
|
var outImg = outImgWrapper.data;
|
||||||
@@ -547,9 +533,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
topRowIdx = topRowIdx + inWidth;
|
topRowIdx = topRowIdx + inWidth;
|
||||||
bottomRowIdx = bottomRowIdx + inWidth;
|
bottomRowIdx = bottomRowIdx + inWidth;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.hsv2rgb = function(hsv, rgb) {
|
CVUtils.hsv2rgb = function(hsv, rgb) {
|
||||||
var h = hsv[0], s = hsv[1], v = hsv[2], c = v * s, x = c * (1 - Math.abs((h / 60) % 2 - 1)), m = v - c, r = 0, g = 0, b = 0;
|
var h = hsv[0], s = hsv[1], v = hsv[2], c = v * s, x = c * (1 - Math.abs((h / 60) % 2 - 1)), m = v - c, r = 0, g = 0, b = 0;
|
||||||
rgb = rgb || [0, 0, 0];
|
rgb = rgb || [0, 0, 0];
|
||||||
|
|
||||||
@@ -576,9 +562,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
rgb[1] = ((g + m) * 255) | 0;
|
rgb[1] = ((g + m) * 255) | 0;
|
||||||
rgb[2] = ((b + m) * 255) | 0;
|
rgb[2] = ((b + m) * 255) | 0;
|
||||||
return rgb;
|
return rgb;
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils._computeDivisors = function(n) {
|
CVUtils._computeDivisors = function(n) {
|
||||||
var largeDivisors = [],
|
var largeDivisors = [],
|
||||||
divisors = [],
|
divisors = [],
|
||||||
i;
|
i;
|
||||||
@@ -592,9 +578,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return divisors.concat(largeDivisors);
|
return divisors.concat(largeDivisors);
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils._computeIntersection = function(arr1, arr2) {
|
CVUtils._computeIntersection = function(arr1, arr2) {
|
||||||
var i = 0,
|
var i = 0,
|
||||||
j = 0,
|
j = 0,
|
||||||
result = [];
|
result = [];
|
||||||
@@ -611,9 +597,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.calculatePatchSize = function(patchSize, imgSize) {
|
CVUtils.calculatePatchSize = function(patchSize, imgSize) {
|
||||||
var divisorsX = this._computeDivisors(imgSize.x),
|
var divisorsX = this._computeDivisors(imgSize.x),
|
||||||
divisorsY = this._computeDivisors(imgSize.y),
|
divisorsY = this._computeDivisors(imgSize.y),
|
||||||
wideSide = Math.max(imgSize.x, imgSize.y),
|
wideSide = Math.max(imgSize.x, imgSize.y),
|
||||||
@@ -660,18 +646,18 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return optimalPatchSize;
|
return optimalPatchSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils._parseCSSDimensionValues = function(value) {
|
CVUtils._parseCSSDimensionValues = function(value) {
|
||||||
var dimension = {
|
var dimension = {
|
||||||
value: parseFloat(value),
|
value: parseFloat(value),
|
||||||
unit: value.indexOf("%") === value.length-1 ? "%" : "%"
|
unit: value.indexOf("%") === value.length-1 ? "%" : "%"
|
||||||
};
|
};
|
||||||
|
|
||||||
return dimension;
|
return dimension;
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils._dimensionsConverters = {
|
CVUtils._dimensionsConverters = {
|
||||||
top: function(dimension, context) {
|
top: function(dimension, context) {
|
||||||
if (dimension.unit === "%") {
|
if (dimension.unit === "%") {
|
||||||
return Math.floor(context.height * (dimension.value / 100));
|
return Math.floor(context.height * (dimension.value / 100));
|
||||||
@@ -692,9 +678,9 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
return Math.floor(context.width * (dimension.value / 100));
|
return Math.floor(context.width * (dimension.value / 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CVUtils.computeImageArea = function(inputWidth, inputHeight, area) {
|
CVUtils.computeImageArea = function(inputWidth, inputHeight, area) {
|
||||||
var context = {width: inputWidth, height: inputHeight};
|
var context = {width: inputWidth, height: inputHeight};
|
||||||
|
|
||||||
var parsedArea = Object.keys(area).reduce(function(result, key) {
|
var parsedArea = Object.keys(area).reduce(function(result, key) {
|
||||||
@@ -712,8 +698,6 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
sw: parsedArea.right - parsedArea.left,
|
sw: parsedArea.right - parsedArea.left,
|
||||||
sh: parsedArea.bottom - parsedArea.top
|
sh: parsedArea.bottom - parsedArea.top
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
return (CVUtils);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
export default CVUtils;
|
||||||
|
|||||||
+10
-20
@@ -1,25 +1,17 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import EANReader from './ean_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
function EAN8Reader() {
|
||||||
[
|
|
||||||
"./ean_reader"
|
|
||||||
],
|
|
||||||
function(EANReader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function EAN8Reader() {
|
|
||||||
EANReader.call(this);
|
EANReader.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
FORMAT: {value: "ean_8", writeable: false}
|
FORMAT: {value: "ean_8", writeable: false}
|
||||||
};
|
};
|
||||||
|
|
||||||
EAN8Reader.prototype = Object.create(EANReader.prototype, properties);
|
EAN8Reader.prototype = Object.create(EANReader.prototype, properties);
|
||||||
EAN8Reader.prototype.constructor = EAN8Reader;
|
EAN8Reader.prototype.constructor = EAN8Reader;
|
||||||
|
|
||||||
EAN8Reader.prototype._decodePayload = function(code, result, decodedCodes) {
|
EAN8Reader.prototype._decodePayload = function(code, result, decodedCodes) {
|
||||||
var i,
|
var i,
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
@@ -48,8 +40,6 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (EAN8Reader);
|
export default EAN8Reader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+26
-36
@@ -1,18 +1,10 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import BarcodeReader from './barcode_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
function EANReader(opts) {
|
||||||
[
|
|
||||||
"./barcode_reader"
|
|
||||||
],
|
|
||||||
function(BarcodeReader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function EANReader(opts) {
|
|
||||||
BarcodeReader.call(this, opts);
|
BarcodeReader.call(this, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
CODE_L_START : {value: 0},
|
CODE_L_START : {value: 0},
|
||||||
MODULO : {value: 7},
|
MODULO : {value: 7},
|
||||||
CODE_G_START : {value: 10},
|
CODE_G_START : {value: 10},
|
||||||
@@ -45,12 +37,12 @@ define(
|
|||||||
SINGLE_CODE_ERROR: {value: 0.67},
|
SINGLE_CODE_ERROR: {value: 0.67},
|
||||||
AVG_CODE_ERROR: {value: 0.27},
|
AVG_CODE_ERROR: {value: 0.27},
|
||||||
FORMAT: {value: "ean_13", writeable: false}
|
FORMAT: {value: "ean_13", writeable: false}
|
||||||
};
|
};
|
||||||
|
|
||||||
EANReader.prototype = Object.create(BarcodeReader.prototype, properties);
|
EANReader.prototype = Object.create(BarcodeReader.prototype, properties);
|
||||||
EANReader.prototype.constructor = EANReader;
|
EANReader.prototype.constructor = EANReader;
|
||||||
|
|
||||||
EANReader.prototype._decodeCode = function(start, coderange) {
|
EANReader.prototype._decodeCode = function(start, coderange) {
|
||||||
var counter = [0, 0, 0, 0],
|
var counter = [0, 0, 0, 0],
|
||||||
i,
|
i,
|
||||||
self = this,
|
self = this,
|
||||||
@@ -99,9 +91,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
EANReader.prototype._findPattern = function(pattern, offset, isWhite, tryHarder, epsilon) {
|
EANReader.prototype._findPattern = function(pattern, offset, isWhite, tryHarder, epsilon) {
|
||||||
var counter = [],
|
var counter = [],
|
||||||
self = this,
|
self = this,
|
||||||
i,
|
i,
|
||||||
@@ -175,9 +167,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
EANReader.prototype._findStart = function() {
|
EANReader.prototype._findStart = function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
leadingWhitespaceStart,
|
leadingWhitespaceStart,
|
||||||
offset = self._nextSet(self._row),
|
offset = self._nextSet(self._row),
|
||||||
@@ -197,9 +189,9 @@ define(
|
|||||||
offset = startInfo.end;
|
offset = startInfo.end;
|
||||||
startInfo = null;
|
startInfo = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EANReader.prototype._verifyTrailingWhitespace = function(endInfo) {
|
EANReader.prototype._verifyTrailingWhitespace = function(endInfo) {
|
||||||
var self = this,
|
var self = this,
|
||||||
trailingWhitespaceEnd;
|
trailingWhitespaceEnd;
|
||||||
|
|
||||||
@@ -210,16 +202,16 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
EANReader.prototype._findEnd = function(offset, isWhite) {
|
EANReader.prototype._findEnd = function(offset, isWhite) {
|
||||||
var self = this,
|
var self = this,
|
||||||
endInfo = self._findPattern(self.STOP_PATTERN, offset, isWhite, false);
|
endInfo = self._findPattern(self.STOP_PATTERN, offset, isWhite, false);
|
||||||
|
|
||||||
return endInfo !== null ? self._verifyTrailingWhitespace(endInfo) : null;
|
return endInfo !== null ? self._verifyTrailingWhitespace(endInfo) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
EANReader.prototype._calculateFirstDigit = function(codeFrequency) {
|
EANReader.prototype._calculateFirstDigit = function(codeFrequency) {
|
||||||
var i,
|
var i,
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
@@ -229,9 +221,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
EANReader.prototype._decodePayload = function(code, result, decodedCodes) {
|
EANReader.prototype._decodePayload = function(code, result, decodedCodes) {
|
||||||
var i,
|
var i,
|
||||||
self = this,
|
self = this,
|
||||||
codeFrequency = 0x0,
|
codeFrequency = 0x0,
|
||||||
@@ -274,9 +266,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
EANReader.prototype._decode = function() {
|
EANReader.prototype._decode = function() {
|
||||||
var startInfo,
|
var startInfo,
|
||||||
self = this,
|
self = this,
|
||||||
code,
|
code,
|
||||||
@@ -317,9 +309,9 @@ define(
|
|||||||
startInfo : startInfo,
|
startInfo : startInfo,
|
||||||
decodedCodes : decodedCodes
|
decodedCodes : decodedCodes
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
EANReader.prototype._checksum = function(result) {
|
EANReader.prototype._checksum = function(result) {
|
||||||
var sum = 0, i;
|
var sum = 0, i;
|
||||||
|
|
||||||
for ( i = result.length - 2; i >= 0; i -= 2) {
|
for ( i = result.length - 2; i >= 0; i -= 2) {
|
||||||
@@ -330,8 +322,6 @@ define(
|
|||||||
sum += result[i];
|
sum += result[i];
|
||||||
}
|
}
|
||||||
return sum % 10 === 0;
|
return sum % 10 === 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (EANReader);
|
export default (EANReader);
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+2
-11
@@ -1,10 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
export default function() {
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var _events = function() {
|
|
||||||
var events = {};
|
var events = {};
|
||||||
|
|
||||||
function getEvent(eventName) {
|
function getEvent(eventName) {
|
||||||
@@ -85,7 +79,4 @@ define(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}();
|
}();
|
||||||
|
|
||||||
return _events;
|
|
||||||
});
|
|
||||||
|
|||||||
+5
-10
@@ -1,12 +1,8 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import CVUtils from './cv_utils';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(["cv_utils"], function(CVUtils) {
|
var FrameGrabber = {};
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var FrameGrabber = {};
|
FrameGrabber.create = function(inputStream, canvas) {
|
||||||
|
|
||||||
FrameGrabber.create = function(inputStream, canvas) {
|
|
||||||
var _that = {},
|
var _that = {},
|
||||||
_streamConfig = inputStream.getConfig(),
|
_streamConfig = inputStream.getConfig(),
|
||||||
_video_size = CVUtils.imageRef(inputStream.getRealWidth(), inputStream.getRealHeight()),
|
_video_size = CVUtils.imageRef(inputStream.getRealWidth(), inputStream.getRealHeight()),
|
||||||
@@ -72,7 +68,6 @@ define(["cv_utils"], function(CVUtils) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return _that;
|
return _that;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (FrameGrabber);
|
export default FrameGrabber;
|
||||||
});
|
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define([], function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function createNode(htmlStr) {
|
|
||||||
var temp = document.createElement('div');
|
|
||||||
|
|
||||||
temp.innerHTML = htmlStr;
|
|
||||||
while (temp.firstChild) {
|
|
||||||
return temp.firstChild;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function mergeObjects(obj1, obj2) {
|
|
||||||
for (var p in obj2) {
|
|
||||||
try {
|
|
||||||
if (obj2[p].constructor == Object) {
|
|
||||||
obj1[p] = mergeObjects(obj1[p], obj2[p]);
|
|
||||||
} else {
|
|
||||||
obj1[p] = obj2[p];
|
|
||||||
}
|
|
||||||
} catch(e) {
|
|
||||||
obj1[p] = obj2[p];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
createNode : function(htmlStr) {
|
|
||||||
return createNode(htmlStr);
|
|
||||||
},
|
|
||||||
mergeObjects : function(obj1, obj2) {
|
|
||||||
return mergeObjects(obj1, obj2);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
+34
-44
@@ -1,34 +1,26 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import BarcodeReader from './barcode_reader';
|
||||||
/* global define */
|
const merge = require('lodash/object/merge');
|
||||||
|
|
||||||
define(
|
function I2of5Reader(opts) {
|
||||||
[
|
opts = merge(getDefaulConfig(), opts);
|
||||||
"./barcode_reader",
|
|
||||||
"./html_utils"
|
|
||||||
],
|
|
||||||
function(BarcodeReader, HTMLUtils) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function I2of5Reader(opts) {
|
|
||||||
opts = HTMLUtils.mergeObjects(getDefaulConfig(), opts);
|
|
||||||
BarcodeReader.call(this, opts);
|
BarcodeReader.call(this, opts);
|
||||||
this.barSpaceRatio = [1, 1];
|
this.barSpaceRatio = [1, 1];
|
||||||
if (opts.normalizeBarSpaceWidth) {
|
if (opts.normalizeBarSpaceWidth) {
|
||||||
this.SINGLE_CODE_ERROR = 0.38;
|
this.SINGLE_CODE_ERROR = 0.38;
|
||||||
this.AVG_CODE_ERROR = 0.09;
|
this.AVG_CODE_ERROR = 0.09;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaulConfig() {
|
function getDefaulConfig() {
|
||||||
var config = {};
|
var config = {};
|
||||||
|
|
||||||
Object.keys(I2of5Reader.CONFIG_KEYS).forEach(function(key) {
|
Object.keys(I2of5Reader.CONFIG_KEYS).forEach(function(key) {
|
||||||
config[key] = I2of5Reader.CONFIG_KEYS[key]['default'];
|
config[key] = I2of5Reader.CONFIG_KEYS[key]['default'];
|
||||||
});
|
});
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
var N = 1,
|
var N = 1,
|
||||||
W = 3,
|
W = 3,
|
||||||
properties = {
|
properties = {
|
||||||
MODULO : {value: 10},
|
MODULO : {value: 10},
|
||||||
@@ -50,12 +42,12 @@ define(
|
|||||||
AVG_CODE_ERROR: {value: 0.38, writable: true},
|
AVG_CODE_ERROR: {value: 0.38, writable: true},
|
||||||
MAX_CORRECTION_FACTOR: {value: 5},
|
MAX_CORRECTION_FACTOR: {value: 5},
|
||||||
FORMAT: {value: "i2of5"}
|
FORMAT: {value: "i2of5"}
|
||||||
};
|
};
|
||||||
|
|
||||||
I2of5Reader.prototype = Object.create(BarcodeReader.prototype, properties);
|
I2of5Reader.prototype = Object.create(BarcodeReader.prototype, properties);
|
||||||
I2of5Reader.prototype.constructor = I2of5Reader;
|
I2of5Reader.prototype.constructor = I2of5Reader;
|
||||||
|
|
||||||
I2of5Reader.prototype._matchPattern = function(counter, code) {
|
I2of5Reader.prototype._matchPattern = function(counter, code) {
|
||||||
if (this.config.normalizeBarSpaceWidth) {
|
if (this.config.normalizeBarSpaceWidth) {
|
||||||
var i,
|
var i,
|
||||||
counterSum = [0, 0],
|
counterSum = [0, 0],
|
||||||
@@ -79,9 +71,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return BarcodeReader.prototype._matchPattern.call(this, counter, code);
|
return BarcodeReader.prototype._matchPattern.call(this, counter, code);
|
||||||
};
|
};
|
||||||
|
|
||||||
I2of5Reader.prototype._findPattern = function(pattern, offset, isWhite, tryHarder) {
|
I2of5Reader.prototype._findPattern = function(pattern, offset, isWhite, tryHarder) {
|
||||||
var counter = [],
|
var counter = [],
|
||||||
self = this,
|
self = this,
|
||||||
i,
|
i,
|
||||||
@@ -147,9 +139,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
I2of5Reader.prototype._findStart = function() {
|
I2of5Reader.prototype._findStart = function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
leadingWhitespaceStart,
|
leadingWhitespaceStart,
|
||||||
offset = self._nextSet(self._row),
|
offset = self._nextSet(self._row),
|
||||||
@@ -171,9 +163,9 @@ define(
|
|||||||
offset = startInfo.end;
|
offset = startInfo.end;
|
||||||
startInfo = null;
|
startInfo = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
I2of5Reader.prototype._verifyTrailingWhitespace = function(endInfo) {
|
I2of5Reader.prototype._verifyTrailingWhitespace = function(endInfo) {
|
||||||
var self = this,
|
var self = this,
|
||||||
trailingWhitespaceEnd;
|
trailingWhitespaceEnd;
|
||||||
|
|
||||||
@@ -184,9 +176,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
I2of5Reader.prototype._findEnd = function() {
|
I2of5Reader.prototype._findEnd = function() {
|
||||||
var self = this,
|
var self = this,
|
||||||
endInfo,
|
endInfo,
|
||||||
tmp;
|
tmp;
|
||||||
@@ -205,9 +197,9 @@ define(
|
|||||||
endInfo.end = self._row.length - tmp;
|
endInfo.end = self._row.length - tmp;
|
||||||
|
|
||||||
return endInfo !== null ? self._verifyTrailingWhitespace(endInfo) : null;
|
return endInfo !== null ? self._verifyTrailingWhitespace(endInfo) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
I2of5Reader.prototype._decodePair = function(counterPair) {
|
I2of5Reader.prototype._decodePair = function(counterPair) {
|
||||||
var i,
|
var i,
|
||||||
code,
|
code,
|
||||||
codes = [],
|
codes = [],
|
||||||
@@ -221,9 +213,9 @@ define(
|
|||||||
codes.push(code);
|
codes.push(code);
|
||||||
}
|
}
|
||||||
return codes;
|
return codes;
|
||||||
};
|
};
|
||||||
|
|
||||||
I2of5Reader.prototype._decodeCode = function(counter) {
|
I2of5Reader.prototype._decodeCode = function(counter) {
|
||||||
var j,
|
var j,
|
||||||
self = this,
|
self = this,
|
||||||
sum = 0,
|
sum = 0,
|
||||||
@@ -255,9 +247,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
I2of5Reader.prototype._decodePayload = function(counters, result, decodedCodes) {
|
I2of5Reader.prototype._decodePayload = function(counters, result, decodedCodes) {
|
||||||
var i,
|
var i,
|
||||||
self = this,
|
self = this,
|
||||||
pos = 0,
|
pos = 0,
|
||||||
@@ -281,13 +273,13 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return codes;
|
return codes;
|
||||||
};
|
};
|
||||||
|
|
||||||
I2of5Reader.prototype._verifyCounterLength = function(counters) {
|
I2of5Reader.prototype._verifyCounterLength = function(counters) {
|
||||||
return (counters.length % 10 === 0);
|
return (counters.length % 10 === 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
I2of5Reader.prototype._decode = function() {
|
I2of5Reader.prototype._decode = function() {
|
||||||
var startInfo,
|
var startInfo,
|
||||||
endInfo,
|
endInfo,
|
||||||
self = this,
|
self = this,
|
||||||
@@ -328,17 +320,15 @@ define(
|
|||||||
startInfo : startInfo,
|
startInfo : startInfo,
|
||||||
decodedCodes : decodedCodes
|
decodedCodes : decodedCodes
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
I2of5Reader.CONFIG_KEYS = {
|
I2of5Reader.CONFIG_KEYS = {
|
||||||
normalizeBarSpaceWidth: {
|
normalizeBarSpaceWidth: {
|
||||||
'type': 'boolean',
|
'type': 'boolean',
|
||||||
'default': false,
|
'default': false,
|
||||||
'description': 'If true, the reader tries to normalize the' +
|
'description': 'If true, the reader tries to normalize the' +
|
||||||
'width-difference between bars and spaces'
|
'width-difference between bars and spaces'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (I2of5Reader);
|
export default I2of5Reader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+2
-10
@@ -1,10 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
export default {
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
return {
|
|
||||||
drawRect: function(pos, size, ctx, style){
|
drawRect: function(pos, size, ctx, style){
|
||||||
ctx.strokeStyle = style.color;
|
ctx.strokeStyle = style.color;
|
||||||
ctx.fillStyle = style.color;
|
ctx.fillStyle = style.color;
|
||||||
@@ -44,6 +38,4 @@ define(function() {
|
|||||||
ctx.putImageData(canvasData, 0, 0);
|
ctx.putImageData(canvasData, 0, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
|
||||||
|
|||||||
+6
-13
@@ -1,11 +1,5 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
var ImageLoader = {};
|
||||||
/* global define */
|
ImageLoader.load = function(directory, callback, offset, size, sequence) {
|
||||||
|
|
||||||
define(function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var ImageLoader = {};
|
|
||||||
ImageLoader.load = function(directory, callback, offset, size, sequence) {
|
|
||||||
var htmlImagesSrcArray = new Array(size),
|
var htmlImagesSrcArray = new Array(size),
|
||||||
htmlImagesArray = new Array(htmlImagesSrcArray.length),
|
htmlImagesArray = new Array(htmlImagesSrcArray.length),
|
||||||
i,
|
i,
|
||||||
@@ -51,13 +45,12 @@ define(function() {
|
|||||||
addOnloadHandler(img, htmlImagesArray);
|
addOnloadHandler(img, htmlImagesArray);
|
||||||
img.src = htmlImagesSrcArray[i];
|
img.src = htmlImagesSrcArray[i];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function addOnloadHandler(img, htmlImagesArray) {
|
function addOnloadHandler(img, htmlImagesArray) {
|
||||||
img.onload = function() {
|
img.onload = function() {
|
||||||
htmlImagesArray.loaded(this);
|
htmlImagesArray.loaded(this);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ImageLoader);
|
export default (ImageLoader);
|
||||||
});
|
|
||||||
|
|||||||
+53
-64
@@ -1,19 +1,9 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import SubImage from './subImage';
|
||||||
/* global define */
|
import CVUtils from './cv_utils';
|
||||||
|
import ArrayHelper from './array_helper';
|
||||||
|
import {vec2, mat2} from 'gl-matrix';
|
||||||
|
|
||||||
define([
|
/**
|
||||||
"subImage",
|
|
||||||
"cv_utils",
|
|
||||||
"array_helper",
|
|
||||||
"gl-matrix"
|
|
||||||
],
|
|
||||||
function(SubImage, CVUtils, ArrayHelper, glMatrix) {
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
var vec2 = glMatrix.vec2,
|
|
||||||
mat2 = glMatrix.mat2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a basic image combining the data and size.
|
* Represents a basic image combining the data and size.
|
||||||
* In addition, some methods for manipulation are contained.
|
* In addition, some methods for manipulation are contained.
|
||||||
* @param size {x,y} The size of the image in pixel
|
* @param size {x,y} The size of the image in pixel
|
||||||
@@ -22,7 +12,7 @@ define([
|
|||||||
* @param initialize {Boolean} Indicating if the array should be initialized on creation.
|
* @param initialize {Boolean} Indicating if the array should be initialized on creation.
|
||||||
* @returns {ImageWrapper}
|
* @returns {ImageWrapper}
|
||||||
*/
|
*/
|
||||||
function ImageWrapper(size, data, ArrayType, initialize) {
|
function ImageWrapper(size, data, ArrayType, initialize) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
if (ArrayType) {
|
if (ArrayType) {
|
||||||
this.data = new ArrayType(size.x * size.y);
|
this.data = new ArrayType(size.x * size.y);
|
||||||
@@ -40,20 +30,20 @@ define([
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tests if a position is within the image with a given offset
|
* tests if a position is within the image with a given offset
|
||||||
* @param imgRef {x, y} The location to test
|
* @param imgRef {x, y} The location to test
|
||||||
* @param border Number the padding value in pixel
|
* @param border Number the padding value in pixel
|
||||||
* @returns {Boolean} true if location inside the image's border, false otherwise
|
* @returns {Boolean} true if location inside the image's border, false otherwise
|
||||||
* @see cvd/image.h
|
* @see cvd/image.h
|
||||||
*/
|
*/
|
||||||
ImageWrapper.prototype.inImageWithBorder = function(imgRef, border) {
|
ImageWrapper.prototype.inImageWithBorder = function(imgRef, border) {
|
||||||
return (imgRef.x >= border) && (imgRef.y >= border) && (imgRef.x < (this.size.x - border)) && (imgRef.y < (this.size.y - border));
|
return (imgRef.x >= border) && (imgRef.y >= border) && (imgRef.x < (this.size.x - border)) && (imgRef.y < (this.size.y - border));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms an image according to the given affine-transformation matrix.
|
* Transforms an image according to the given affine-transformation matrix.
|
||||||
* @param inImg ImageWrapper a image containing the information to be extracted.
|
* @param inImg ImageWrapper a image containing the information to be extracted.
|
||||||
* @param outImg ImageWrapper the image to be filled. The whole image out image is filled by the in image.
|
* @param outImg ImageWrapper the image to be filled. The whole image out image is filled by the in image.
|
||||||
@@ -63,7 +53,7 @@ define([
|
|||||||
* @returns Number the number of pixels not in the in image
|
* @returns Number the number of pixels not in the in image
|
||||||
* @see cvd/vision.h
|
* @see cvd/vision.h
|
||||||
*/
|
*/
|
||||||
ImageWrapper.transform = function(inImg, outImg, M, inOrig, outOrig) {
|
ImageWrapper.transform = function(inImg, outImg, M, inOrig, outOrig) {
|
||||||
var w = outImg.size.x, h = outImg.size.y, iw = inImg.size.x, ih = inImg.size.y;
|
var w = outImg.size.x, h = outImg.size.y, iw = inImg.size.x, ih = inImg.size.y;
|
||||||
var across = vec2.clone([M[0], M[2]]);
|
var across = vec2.clone([M[0], M[2]]);
|
||||||
var down = vec2.clone([M[1], M[3]]);
|
var down = vec2.clone([M[1], M[3]]);
|
||||||
@@ -121,9 +111,9 @@ define([
|
|||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs bilinear sampling
|
* Performs bilinear sampling
|
||||||
* @param inImg Image to extract sample from
|
* @param inImg Image to extract sample from
|
||||||
* @param x the x-coordinate
|
* @param x the x-coordinate
|
||||||
@@ -131,7 +121,7 @@ define([
|
|||||||
* @returns the sampled value
|
* @returns the sampled value
|
||||||
* @see cvd/vision.h
|
* @see cvd/vision.h
|
||||||
*/
|
*/
|
||||||
ImageWrapper.sample = function(inImg, x, y) {
|
ImageWrapper.sample = function(inImg, x, y) {
|
||||||
var lx = Math.floor(x);
|
var lx = Math.floor(x);
|
||||||
var ly = Math.floor(y);
|
var ly = Math.floor(y);
|
||||||
var w = inImg.size.x;
|
var w = inImg.size.x;
|
||||||
@@ -146,35 +136,35 @@ define([
|
|||||||
|
|
||||||
var result = Math.floor(x * (y * (e - c + d) - e) + y * (c - a) + a);
|
var result = Math.floor(x * (y * (e - c + d) - e) + y * (c - a) + a);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a given array. Sets each element to zero.
|
* Initializes a given array. Sets each element to zero.
|
||||||
* @param array {Array} The array to initialize
|
* @param array {Array} The array to initialize
|
||||||
*/
|
*/
|
||||||
ImageWrapper.clearArray = function(array) {
|
ImageWrapper.clearArray = function(array) {
|
||||||
var l = array.length;
|
var l = array.length;
|
||||||
while (l--) {
|
while (l--) {
|
||||||
array[l] = 0;
|
array[l] = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {SubImage} from the current image ({this}).
|
* Creates a {SubImage} from the current image ({this}).
|
||||||
* @param from {ImageRef} The position where to start the {SubImage} from. (top-left corner)
|
* @param from {ImageRef} The position where to start the {SubImage} from. (top-left corner)
|
||||||
* @param size {ImageRef} The size of the resulting image
|
* @param size {ImageRef} The size of the resulting image
|
||||||
* @returns {SubImage} A shared part of the original image
|
* @returns {SubImage} A shared part of the original image
|
||||||
*/
|
*/
|
||||||
ImageWrapper.prototype.subImage = function(from, size) {
|
ImageWrapper.prototype.subImage = function(from, size) {
|
||||||
return new SubImage(from, size, this);
|
return new SubImage(from, size, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an {ImageWrapper) and copies the needed underlying image-data area
|
* Creates an {ImageWrapper) and copies the needed underlying image-data area
|
||||||
* @param imageWrapper {ImageWrapper} The target {ImageWrapper} where the data should be copied
|
* @param imageWrapper {ImageWrapper} The target {ImageWrapper} where the data should be copied
|
||||||
* @param from {ImageRef} The location where to copy from (top-left location)
|
* @param from {ImageRef} The location where to copy from (top-left location)
|
||||||
*/
|
*/
|
||||||
ImageWrapper.prototype.subImageAsCopy = function(imageWrapper, from) {
|
ImageWrapper.prototype.subImageAsCopy = function(imageWrapper, from) {
|
||||||
var sizeY = imageWrapper.size.y, sizeX = imageWrapper.size.x;
|
var sizeY = imageWrapper.size.y, sizeX = imageWrapper.size.x;
|
||||||
var x, y;
|
var x, y;
|
||||||
for ( x = 0; x < sizeX; x++) {
|
for ( x = 0; x < sizeX; x++) {
|
||||||
@@ -182,33 +172,33 @@ define([
|
|||||||
imageWrapper.data[y * sizeX + x] = this.data[(from.y + y) * this.size.x + from.x + x];
|
imageWrapper.data[y * sizeX + x] = this.data[(from.y + y) * this.size.x + from.x + x];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ImageWrapper.prototype.copyTo = function(imageWrapper) {
|
ImageWrapper.prototype.copyTo = function(imageWrapper) {
|
||||||
var length = this.data.length, srcData = this.data, dstData = imageWrapper.data;
|
var length = this.data.length, srcData = this.data, dstData = imageWrapper.data;
|
||||||
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
dstData[length] = srcData[length];
|
dstData[length] = srcData[length];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a given pixel position from the image
|
* Retrieves a given pixel position from the image
|
||||||
* @param x {Number} The x-position
|
* @param x {Number} The x-position
|
||||||
* @param y {Number} The y-position
|
* @param y {Number} The y-position
|
||||||
* @returns {Number} The grayscale value at the pixel-position
|
* @returns {Number} The grayscale value at the pixel-position
|
||||||
*/
|
*/
|
||||||
ImageWrapper.prototype.get = function(x, y) {
|
ImageWrapper.prototype.get = function(x, y) {
|
||||||
return this.data[y * this.size.x + x];
|
return this.data[y * this.size.x + x];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a given pixel position from the image
|
* Retrieves a given pixel position from the image
|
||||||
* @param x {Number} The x-position
|
* @param x {Number} The x-position
|
||||||
* @param y {Number} The y-position
|
* @param y {Number} The y-position
|
||||||
* @returns {Number} The grayscale value at the pixel-position
|
* @returns {Number} The grayscale value at the pixel-position
|
||||||
*/
|
*/
|
||||||
ImageWrapper.prototype.getSafe = function(x, y) {
|
ImageWrapper.prototype.getSafe = function(x, y) {
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
if (!this.indexMapping) {
|
if (!this.indexMapping) {
|
||||||
@@ -226,24 +216,24 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.data[(this.indexMapping.y[y + this.size.y]) * this.size.x + this.indexMapping.x[x + this.size.x]];
|
return this.data[(this.indexMapping.y[y + this.size.y]) * this.size.x + this.indexMapping.x[x + this.size.x]];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a given pixel position in the image
|
* Sets a given pixel position in the image
|
||||||
* @param x {Number} The x-position
|
* @param x {Number} The x-position
|
||||||
* @param y {Number} The y-position
|
* @param y {Number} The y-position
|
||||||
* @param value {Number} The grayscale value to set
|
* @param value {Number} The grayscale value to set
|
||||||
* @returns {ImageWrapper} The Image itself (for possible chaining)
|
* @returns {ImageWrapper} The Image itself (for possible chaining)
|
||||||
*/
|
*/
|
||||||
ImageWrapper.prototype.set = function(x, y, value) {
|
ImageWrapper.prototype.set = function(x, y, value) {
|
||||||
this.data[y * this.size.x + x] = value;
|
this.data[y * this.size.x + x] = value;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the border of the image (1 pixel) to zero
|
* Sets the border of the image (1 pixel) to zero
|
||||||
*/
|
*/
|
||||||
ImageWrapper.prototype.zeroBorder = function() {
|
ImageWrapper.prototype.zeroBorder = function() {
|
||||||
var i, width = this.size.x, height = this.size.y, data = this.data;
|
var i, width = this.size.x, height = this.size.y, data = this.data;
|
||||||
for ( i = 0; i < width; i++) {
|
for ( i = 0; i < width; i++) {
|
||||||
data[i] = data[(height - 1) * width + i] = 0;
|
data[i] = data[(height - 1) * width + i] = 0;
|
||||||
@@ -251,21 +241,21 @@ define([
|
|||||||
for ( i = 1; i < height - 1; i++) {
|
for ( i = 1; i < height - 1; i++) {
|
||||||
data[i * width] = data[i * width + (width - 1)] = 0;
|
data[i * width] = data[i * width + (width - 1)] = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inverts a binary image in place
|
* Inverts a binary image in place
|
||||||
*/
|
*/
|
||||||
ImageWrapper.prototype.invert = function() {
|
ImageWrapper.prototype.invert = function() {
|
||||||
var data = this.data, length = data.length;
|
var data = this.data, length = data.length;
|
||||||
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
data[length] = data[length] ? 0 : 1;
|
data[length] = data[length] ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ImageWrapper.prototype.convolve = function(kernel) {
|
ImageWrapper.prototype.convolve = function(kernel) {
|
||||||
var x, y, kx, ky, kSize = (kernel.length / 2) | 0, accu = 0;
|
var x, y, kx, ky, kSize = (kernel.length / 2) | 0, accu = 0;
|
||||||
for ( y = 0; y < this.size.y; y++) {
|
for ( y = 0; y < this.size.y; y++) {
|
||||||
for ( x = 0; x < this.size.x; x++) {
|
for ( x = 0; x < this.size.x; x++) {
|
||||||
@@ -278,9 +268,9 @@ define([
|
|||||||
this.data[y * this.size.x + x] = accu;
|
this.data[y * this.size.x + x] = accu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ImageWrapper.prototype.moments = function(labelcount) {
|
ImageWrapper.prototype.moments = function(labelcount) {
|
||||||
var data = this.data,
|
var data = this.data,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
@@ -355,14 +345,14 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the {ImageWrapper} in a given canvas
|
* Displays the {ImageWrapper} in a given canvas
|
||||||
* @param canvas {Canvas} The canvas element to write to
|
* @param canvas {Canvas} The canvas element to write to
|
||||||
* @param scale {Number} Scale which is applied to each pixel-value
|
* @param scale {Number} Scale which is applied to each pixel-value
|
||||||
*/
|
*/
|
||||||
ImageWrapper.prototype.show = function(canvas, scale) {
|
ImageWrapper.prototype.show = function(canvas, scale) {
|
||||||
var ctx,
|
var ctx,
|
||||||
frame,
|
frame,
|
||||||
data,
|
data,
|
||||||
@@ -392,14 +382,14 @@ define([
|
|||||||
}
|
}
|
||||||
//frame.data = data;
|
//frame.data = data;
|
||||||
ctx.putImageData(frame, 0, 0);
|
ctx.putImageData(frame, 0, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the {SubImage} in a given canvas
|
* Displays the {SubImage} in a given canvas
|
||||||
* @param canvas {Canvas} The canvas element to write to
|
* @param canvas {Canvas} The canvas element to write to
|
||||||
* @param scale {Number} Scale which is applied to each pixel-value
|
* @param scale {Number} Scale which is applied to each pixel-value
|
||||||
*/
|
*/
|
||||||
ImageWrapper.prototype.overlay = function(canvas, scale, from) {
|
ImageWrapper.prototype.overlay = function(canvas, scale, from) {
|
||||||
if (!scale || scale < 0 || scale > 360) {
|
if (!scale || scale < 0 || scale > 360) {
|
||||||
scale = 360;
|
scale = 360;
|
||||||
}
|
}
|
||||||
@@ -421,7 +411,6 @@ define([
|
|||||||
data[length * 4 + 3] = 255;
|
data[length * 4 + 3] = 255;
|
||||||
}
|
}
|
||||||
ctx.putImageData(frame, from.x, from.y);
|
ctx.putImageData(frame, from.x, from.y);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (ImageWrapper);
|
export default ImageWrapper;
|
||||||
});
|
|
||||||
|
|||||||
+9
-14
@@ -1,11 +1,7 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import ImageLoader from './image_loader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(["image_loader"], function(ImageLoader) {
|
var InputStream = {};
|
||||||
"use strict";
|
InputStream.createVideoStream = function(video) {
|
||||||
|
|
||||||
var InputStream = {};
|
|
||||||
InputStream.createVideoStream = function(video) {
|
|
||||||
var that = {},
|
var that = {},
|
||||||
_config = null,
|
_config = null,
|
||||||
_eventNames = ['canrecord', 'ended'],
|
_eventNames = ['canrecord', 'ended'],
|
||||||
@@ -139,9 +135,9 @@ define(["image_loader"], function(ImageLoader) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
InputStream.createLiveStream = function(video) {
|
InputStream.createLiveStream = function(video) {
|
||||||
video.setAttribute("autoplay", true);
|
video.setAttribute("autoplay", true);
|
||||||
var that = InputStream.createVideoStream(video);
|
var that = InputStream.createVideoStream(video);
|
||||||
|
|
||||||
@@ -150,9 +146,9 @@ define(["image_loader"], function(ImageLoader) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
InputStream.createImageStream = function() {
|
InputStream.createImageStream = function() {
|
||||||
var that = {};
|
var that = {};
|
||||||
var _config = null;
|
var _config = null;
|
||||||
|
|
||||||
@@ -311,7 +307,6 @@ define(["image_loader"], function(ImageLoader) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (InputStream);
|
export default InputStream;
|
||||||
});
|
|
||||||
|
|||||||
+58
-72
@@ -1,33 +1,19 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true, evil: true */
|
import TypeDefs from './typedefs';
|
||||||
/* global define */
|
import InputStream from './input_stream';
|
||||||
define([
|
import ImageWrapper from './image_wrapper';
|
||||||
"input_stream",
|
import BarcodeLocator from './barcode_locator';
|
||||||
"image_wrapper",
|
import BarcodeDecoder from './barcode_decoder';
|
||||||
"barcode_locator",
|
import FrameGrabber from './frame_grabber';
|
||||||
"barcode_decoder",
|
import Config from './config';
|
||||||
"frame_grabber",
|
import Events from './events';
|
||||||
"html_utils",
|
import CameraAccess from './camera_access';
|
||||||
"config",
|
import ImageDebug from './image_debug';
|
||||||
"events",
|
import {vec2} from 'gl-matrix';
|
||||||
"camera_access",
|
import ResultCollector from './result_collector';
|
||||||
"image_debug",
|
|
||||||
"gl-matrix",
|
|
||||||
"result_collector"],
|
|
||||||
function(InputStream,
|
|
||||||
ImageWrapper,
|
|
||||||
BarcodeLocator,
|
|
||||||
BarcodeDecoder,
|
|
||||||
FrameGrabber,
|
|
||||||
HtmlUtils,
|
|
||||||
_config,
|
|
||||||
Events,
|
|
||||||
CameraAccess,
|
|
||||||
ImageDebug,
|
|
||||||
glMatrix,
|
|
||||||
ResultCollector) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var _inputStream,
|
const merge = require('lodash/object/merge');
|
||||||
|
|
||||||
|
var _inputStream,
|
||||||
_framegrabber,
|
_framegrabber,
|
||||||
_stopped,
|
_stopped,
|
||||||
_canvasContainer = {
|
_canvasContainer = {
|
||||||
@@ -45,15 +31,15 @@ function(InputStream,
|
|||||||
_decoder,
|
_decoder,
|
||||||
_workerPool = [],
|
_workerPool = [],
|
||||||
_onUIThread = true,
|
_onUIThread = true,
|
||||||
vec2 = glMatrix.vec2,
|
_resultCollector,
|
||||||
_resultCollector;
|
_config = {};
|
||||||
|
|
||||||
function initializeData(imageWrapper) {
|
function initializeData(imageWrapper) {
|
||||||
initBuffers(imageWrapper);
|
initBuffers(imageWrapper);
|
||||||
_decoder = BarcodeDecoder.create(_config.decoder, _inputImageWrapper);
|
_decoder = BarcodeDecoder.create(_config.decoder, _inputImageWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initConfig() {
|
function initConfig() {
|
||||||
if (typeof document !== "undefined") {
|
if (typeof document !== "undefined") {
|
||||||
var vis = [{
|
var vis = [{
|
||||||
node: document.querySelector("div[data-controls]"),
|
node: document.querySelector("div[data-controls]"),
|
||||||
@@ -73,9 +59,9 @@ function(InputStream,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initInputStream(cb) {
|
function initInputStream(cb) {
|
||||||
var video;
|
var video;
|
||||||
if (_config.inputStream.type == "VideoStream") {
|
if (_config.inputStream.type == "VideoStream") {
|
||||||
video = document.createElement("video");
|
video = document.createElement("video");
|
||||||
@@ -105,9 +91,9 @@ function(InputStream,
|
|||||||
_inputStream.setAttribute("autoplay", true);
|
_inputStream.setAttribute("autoplay", true);
|
||||||
_inputStream.setInputStream(_config.inputStream);
|
_inputStream.setInputStream(_config.inputStream);
|
||||||
_inputStream.addEventListener("canrecord", canRecord.bind(undefined, cb));
|
_inputStream.addEventListener("canrecord", canRecord.bind(undefined, cb));
|
||||||
}
|
}
|
||||||
|
|
||||||
function canRecord(cb) {
|
function canRecord(cb) {
|
||||||
BarcodeLocator.checkImageConstraints(_inputStream, _config.locator);
|
BarcodeLocator.checkImageConstraints(_inputStream, _config.locator);
|
||||||
initCanvas();
|
initCanvas();
|
||||||
_framegrabber = FrameGrabber.create(_inputStream, _canvasContainer.dom.image);
|
_framegrabber = FrameGrabber.create(_inputStream, _canvasContainer.dom.image);
|
||||||
@@ -122,14 +108,14 @@ function(InputStream,
|
|||||||
initializeData();
|
initializeData();
|
||||||
ready(cb);
|
ready(cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ready(cb){
|
function ready(cb){
|
||||||
_inputStream.play();
|
_inputStream.play();
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
function initCanvas() {
|
function initCanvas() {
|
||||||
if (typeof document !== "undefined") {
|
if (typeof document !== "undefined") {
|
||||||
var $viewport = document.querySelector("#interactive.viewport");
|
var $viewport = document.querySelector("#interactive.viewport");
|
||||||
_canvasContainer.dom.image = document.querySelector("canvas.imgBuffer");
|
_canvasContainer.dom.image = document.querySelector("canvas.imgBuffer");
|
||||||
@@ -161,9 +147,9 @@ function(InputStream,
|
|||||||
_canvasContainer.dom.overlay.width = _inputStream.getCanvasSize().x;
|
_canvasContainer.dom.overlay.width = _inputStream.getCanvasSize().x;
|
||||||
_canvasContainer.dom.overlay.height = _inputStream.getCanvasSize().y;
|
_canvasContainer.dom.overlay.height = _inputStream.getCanvasSize().y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initBuffers(imageWrapper) {
|
function initBuffers(imageWrapper) {
|
||||||
if (imageWrapper) {
|
if (imageWrapper) {
|
||||||
_inputImageWrapper = imageWrapper;
|
_inputImageWrapper = imageWrapper;
|
||||||
} else {
|
} else {
|
||||||
@@ -181,9 +167,9 @@ function(InputStream,
|
|||||||
vec2.clone([_inputImageWrapper.size.x, 0])
|
vec2.clone([_inputImageWrapper.size.x, 0])
|
||||||
];
|
];
|
||||||
BarcodeLocator.init(_inputImageWrapper, _config.locator);
|
BarcodeLocator.init(_inputImageWrapper, _config.locator);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBoundingBoxes() {
|
function getBoundingBoxes() {
|
||||||
if (_config.locate) {
|
if (_config.locate) {
|
||||||
return BarcodeLocator.locate();
|
return BarcodeLocator.locate();
|
||||||
} else {
|
} else {
|
||||||
@@ -193,9 +179,9 @@ function(InputStream,
|
|||||||
vec2.clone(_boxSize[2]),
|
vec2.clone(_boxSize[2]),
|
||||||
vec2.clone(_boxSize[3])]];
|
vec2.clone(_boxSize[3])]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function transformResult(result) {
|
function transformResult(result) {
|
||||||
var topRight = _inputStream.getTopRight(),
|
var topRight = _inputStream.getTopRight(),
|
||||||
xOffset = topRight.x,
|
xOffset = topRight.x,
|
||||||
yOffset = topRight.y,
|
yOffset = topRight.y,
|
||||||
@@ -230,9 +216,9 @@ function(InputStream,
|
|||||||
line[1].x += xOffset;
|
line[1].x += xOffset;
|
||||||
line[1].y += yOffset;
|
line[1].y += yOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function publishResult(result, imageData) {
|
function publishResult(result, imageData) {
|
||||||
if (_onUIThread) {
|
if (_onUIThread) {
|
||||||
transformResult(result);
|
transformResult(result);
|
||||||
if (imageData && result && result.codeResult) {
|
if (imageData && result && result.codeResult) {
|
||||||
@@ -246,9 +232,9 @@ function(InputStream,
|
|||||||
if (result && result.codeResult) {
|
if (result && result.codeResult) {
|
||||||
Events.publish("detected", result);
|
Events.publish("detected", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function locateAndDecode() {
|
function locateAndDecode() {
|
||||||
var result,
|
var result,
|
||||||
boxes;
|
boxes;
|
||||||
|
|
||||||
@@ -261,9 +247,9 @@ function(InputStream,
|
|||||||
} else {
|
} else {
|
||||||
publishResult();
|
publishResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
var availableWorker;
|
var availableWorker;
|
||||||
|
|
||||||
if (_onUIThread) {
|
if (_onUIThread) {
|
||||||
@@ -293,9 +279,9 @@ function(InputStream,
|
|||||||
} else {
|
} else {
|
||||||
locateAndDecode();
|
locateAndDecode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
_stopped = false;
|
_stopped = false;
|
||||||
( function frame() {
|
( function frame() {
|
||||||
if (!_stopped) {
|
if (!_stopped) {
|
||||||
@@ -305,9 +291,9 @@ function(InputStream,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
|
|
||||||
function initWorkers(cb) {
|
function initWorkers(cb) {
|
||||||
var i;
|
var i;
|
||||||
_workerPool = [];
|
_workerPool = [];
|
||||||
|
|
||||||
@@ -321,9 +307,9 @@ function(InputStream,
|
|||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initWorker(cb) {
|
function initWorker(cb) {
|
||||||
var blobURL,
|
var blobURL,
|
||||||
workerThread = {
|
workerThread = {
|
||||||
worker: undefined,
|
worker: undefined,
|
||||||
@@ -356,10 +342,11 @@ function(InputStream,
|
|||||||
imageData: workerThread.imageData,
|
imageData: workerThread.imageData,
|
||||||
config: _config
|
config: _config
|
||||||
}, [workerThread.imageData.buffer]);
|
}, [workerThread.imageData.buffer]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function workerInterface(factory) {
|
function workerInterface(factory) {
|
||||||
|
window = self;
|
||||||
if (factory) {
|
if (factory) {
|
||||||
/* jshint ignore:start */
|
/* jshint ignore:start */
|
||||||
var Quagga = factory();
|
var Quagga = factory();
|
||||||
@@ -398,9 +385,9 @@ function(InputStream,
|
|||||||
self.postMessage({'event': 'initialized', imageData: imageWrapper.data}, [imageWrapper.data.buffer]);
|
self.postMessage({'event': 'initialized', imageData: imageWrapper.data}, [imageWrapper.data.buffer]);
|
||||||
}
|
}
|
||||||
/* jshint ignore:end */
|
/* jshint ignore:end */
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateWorkerBlob() {
|
function generateWorkerBlob() {
|
||||||
var blob,
|
var blob,
|
||||||
factorySource;
|
factorySource;
|
||||||
|
|
||||||
@@ -414,9 +401,9 @@ function(InputStream,
|
|||||||
{type : 'text/javascript'});
|
{type : 'text/javascript'});
|
||||||
|
|
||||||
return window.URL.createObjectURL(blob);
|
return window.URL.createObjectURL(blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setReaders(readers) {
|
function setReaders(readers) {
|
||||||
if (_decoder) {
|
if (_decoder) {
|
||||||
_decoder.setReaders(readers);
|
_decoder.setReaders(readers);
|
||||||
} else if (_onUIThread && _workerPool.length > 0) {
|
} else if (_onUIThread && _workerPool.length > 0) {
|
||||||
@@ -424,11 +411,11 @@ function(InputStream,
|
|||||||
workerThread.worker.postMessage({cmd: 'setReaders', readers: readers});
|
workerThread.worker.postMessage({cmd: 'setReaders', readers: readers});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
export default {
|
||||||
init : function(config, cb, imageWrapper) {
|
init : function(config, cb, imageWrapper) {
|
||||||
_config = HtmlUtils.mergeObjects(_config, config);
|
_config = merge({}, Config, config);
|
||||||
if (imageWrapper) {
|
if (imageWrapper) {
|
||||||
_onUIThread = false;
|
_onUIThread = false;
|
||||||
initializeData(imageWrapper);
|
initializeData(imageWrapper);
|
||||||
@@ -477,7 +464,7 @@ function(InputStream,
|
|||||||
},
|
},
|
||||||
canvas : _canvasContainer,
|
canvas : _canvasContainer,
|
||||||
decodeSingle : function(config, resultCallback) {
|
decodeSingle : function(config, resultCallback) {
|
||||||
config = HtmlUtils.mergeObjects({
|
config = merge({
|
||||||
inputStream: {
|
inputStream: {
|
||||||
type : "ImageStream",
|
type : "ImageStream",
|
||||||
sequence : false,
|
sequence : false,
|
||||||
@@ -500,5 +487,4 @@ function(InputStream,
|
|||||||
ImageWrapper: ImageWrapper,
|
ImageWrapper: ImageWrapper,
|
||||||
ImageDebug: ImageDebug,
|
ImageDebug: ImageDebug,
|
||||||
ResultCollector: ResultCollector
|
ResultCollector: ResultCollector
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|||||||
+4
-9
@@ -1,13 +1,9 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import Tracer from './tracer';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http://www.codeproject.com/Tips/407172/Connected-Component-Labeling-and-Vectorization
|
* http://www.codeproject.com/Tips/407172/Connected-Component-Labeling-and-Vectorization
|
||||||
*/
|
*/
|
||||||
define(["tracer"], function(Tracer) {
|
var Rasterizer = {
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var Rasterizer = {
|
|
||||||
createContour2D : function() {
|
createContour2D : function() {
|
||||||
return {
|
return {
|
||||||
dir : null,
|
dir : null,
|
||||||
@@ -192,7 +188,6 @@ define(["tracer"], function(Tracer) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Rasterizer);
|
export default Rasterizer;
|
||||||
});
|
|
||||||
|
|||||||
+7
-12
@@ -1,10 +1,6 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import ImageDebug from './image_debug';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(["image_debug"], function(ImageDebug) {
|
function contains(codeResult, list) {
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function contains(codeResult, list) {
|
|
||||||
if (list) {
|
if (list) {
|
||||||
return list.some(function (item) {
|
return list.some(function (item) {
|
||||||
return Object.keys(item).every(function (key) {
|
return Object.keys(item).every(function (key) {
|
||||||
@@ -13,16 +9,16 @@ define(["image_debug"], function(ImageDebug) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function passesFilter(codeResult, filter) {
|
function passesFilter(codeResult, filter) {
|
||||||
if (typeof filter === 'function') {
|
if (typeof filter === 'function') {
|
||||||
return filter(codeResult);
|
return filter(codeResult);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
export default {
|
||||||
create: function(config) {
|
create: function(config) {
|
||||||
var canvas = document.createElement("canvas"),
|
var canvas = document.createElement("canvas"),
|
||||||
ctx = canvas.getContext("2d"),
|
ctx = canvas.getContext("2d"),
|
||||||
@@ -55,5 +51,4 @@ define(["image_debug"], function(ImageDebug) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|||||||
+5
-12
@@ -1,11 +1,5 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true, -W041: false */
|
/* @preserve ASM BEGIN */
|
||||||
/* global define */
|
function Skeletonizer(stdlib, foreign, buffer) {
|
||||||
|
|
||||||
define(function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/* @preserve ASM BEGIN */
|
|
||||||
function Skeletonizer(stdlib, foreign, buffer) {
|
|
||||||
"use asm";
|
"use asm";
|
||||||
|
|
||||||
var images = new stdlib.Uint8Array(buffer),
|
var images = new stdlib.Uint8Array(buffer),
|
||||||
@@ -197,8 +191,7 @@ define(function() {
|
|||||||
return {
|
return {
|
||||||
skeletonize : skeletonize
|
skeletonize : skeletonize
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/* @preserve ASM END */
|
/* @preserve ASM END */
|
||||||
|
|
||||||
return Skeletonizer;
|
export default Skeletonizer;
|
||||||
});
|
|
||||||
|
|||||||
+16
-23
@@ -1,10 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
/**
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(["typedefs"], function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct representing a part of another {ImageWrapper}. Shares data
|
* Construct representing a part of another {ImageWrapper}. Shares data
|
||||||
* between the parent and the child.
|
* between the parent and the child.
|
||||||
* @param from {ImageRef} The position where to start the {SubImage} from. (top-left corner)
|
* @param from {ImageRef} The position where to start the {SubImage} from. (top-left corner)
|
||||||
@@ -12,7 +6,7 @@ define(["typedefs"], function() {
|
|||||||
* @param I {ImageWrapper} The {ImageWrapper} to share from
|
* @param I {ImageWrapper} The {ImageWrapper} to share from
|
||||||
* @returns {SubImage} A shared part of the original image
|
* @returns {SubImage} A shared part of the original image
|
||||||
*/
|
*/
|
||||||
function SubImage(from, size, I) {
|
function SubImage(from, size, I) {
|
||||||
if (!I) {
|
if (!I) {
|
||||||
I = {
|
I = {
|
||||||
data : null,
|
data : null,
|
||||||
@@ -25,14 +19,14 @@ define(["typedefs"], function() {
|
|||||||
|
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the {SubImage} in a given canvas
|
* Displays the {SubImage} in a given canvas
|
||||||
* @param canvas {Canvas} The canvas element to write to
|
* @param canvas {Canvas} The canvas element to write to
|
||||||
* @param scale {Number} Scale which is applied to each pixel-value
|
* @param scale {Number} Scale which is applied to each pixel-value
|
||||||
*/
|
*/
|
||||||
SubImage.prototype.show = function(canvas, scale) {
|
SubImage.prototype.show = function(canvas, scale) {
|
||||||
var ctx,
|
var ctx,
|
||||||
frame,
|
frame,
|
||||||
data,
|
data,
|
||||||
@@ -62,36 +56,35 @@ define(["typedefs"], function() {
|
|||||||
}
|
}
|
||||||
frame.data = data;
|
frame.data = data;
|
||||||
ctx.putImageData(frame, 0, 0);
|
ctx.putImageData(frame, 0, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a given pixel position from the {SubImage}
|
* Retrieves a given pixel position from the {SubImage}
|
||||||
* @param x {Number} The x-position
|
* @param x {Number} The x-position
|
||||||
* @param y {Number} The y-position
|
* @param y {Number} The y-position
|
||||||
* @returns {Number} The grayscale value at the pixel-position
|
* @returns {Number} The grayscale value at the pixel-position
|
||||||
*/
|
*/
|
||||||
SubImage.prototype.get = function(x, y) {
|
SubImage.prototype.get = function(x, y) {
|
||||||
return this.data[(this.from.y + y) * this.originalSize.x + this.from.x + x];
|
return this.data[(this.from.y + y) * this.originalSize.x + this.from.x + x];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the underlying data from a given {ImageWrapper}
|
* Updates the underlying data from a given {ImageWrapper}
|
||||||
* @param image {ImageWrapper} The updated image
|
* @param image {ImageWrapper} The updated image
|
||||||
*/
|
*/
|
||||||
SubImage.prototype.updateData = function(image) {
|
SubImage.prototype.updateData = function(image) {
|
||||||
this.originalSize = image.size;
|
this.originalSize = image.size;
|
||||||
this.data = image.data;
|
this.data = image.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the position of the shared area
|
* Updates the position of the shared area
|
||||||
* @param from {x,y} The new location
|
* @param from {x,y} The new location
|
||||||
* @returns {SubImage} returns {this} for possible chaining
|
* @returns {SubImage} returns {this} for possible chaining
|
||||||
*/
|
*/
|
||||||
SubImage.prototype.updateFrom = function(from) {
|
SubImage.prototype.updateFrom = function(from) {
|
||||||
this.from = from;
|
this.from = from;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (SubImage);
|
export default (SubImage);
|
||||||
});
|
|
||||||
|
|||||||
+3
-10
@@ -1,13 +1,7 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
|
||||||
/* global define */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http://www.codeproject.com/Tips/407172/Connected-Component-Labeling-and-Vectorization
|
* http://www.codeproject.com/Tips/407172/Connected-Component-Labeling-and-Vectorization
|
||||||
*/
|
*/
|
||||||
define(function() {
|
var Tracer = {
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var Tracer = {
|
|
||||||
searchDirections : [[0, 1], [1, 1], [1, 0], [1, -1], [0, -1], [-1, -1], [-1, 0], [-1, 1]],
|
searchDirections : [[0, 1], [1, 1], [1, 0], [1, -1], [0, -1], [-1, -1], [-1, 0], [-1, 1]],
|
||||||
create : function(imageWrapper, labelWrapper) {
|
create : function(imageWrapper, labelWrapper) {
|
||||||
var imageData = imageWrapper.data,
|
var imageData = imageWrapper.data,
|
||||||
@@ -102,7 +96,6 @@ define(function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Tracer);
|
export default (Tracer);
|
||||||
});
|
|
||||||
|
|||||||
+8
-5
@@ -3,8 +3,7 @@
|
|||||||
* Normalizes browser-specific prefixes
|
* Normalizes browser-specific prefixes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
glMatrixArrayType = Float32Array;
|
if (typeof window !== 'undefined') {
|
||||||
if (typeof window !== 'undefined') {
|
|
||||||
window.requestAnimFrame = (function () {
|
window.requestAnimFrame = (function () {
|
||||||
return window.requestAnimationFrame ||
|
return window.requestAnimationFrame ||
|
||||||
window.webkitRequestAnimationFrame ||
|
window.webkitRequestAnimationFrame ||
|
||||||
@@ -18,8 +17,8 @@ if (typeof window !== 'undefined') {
|
|||||||
|
|
||||||
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
||||||
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
|
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
|
||||||
}
|
}
|
||||||
Math.imul = Math.imul || function(a, b) {
|
Math.imul = Math.imul || function(a, b) {
|
||||||
var ah = (a >>> 16) & 0xffff,
|
var ah = (a >>> 16) & 0xffff,
|
||||||
al = a & 0xffff,
|
al = a & 0xffff,
|
||||||
bh = (b >>> 16) & 0xffff,
|
bh = (b >>> 16) & 0xffff,
|
||||||
@@ -27,4 +26,8 @@ Math.imul = Math.imul || function(a, b) {
|
|||||||
// the shift by 0 fixes the sign on the high part
|
// the shift by 0 fixes the sign on the high part
|
||||||
// the final |0 converts the unsigned value into a signed value
|
// the final |0 converts the unsigned value into a signed value
|
||||||
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
|
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
+20
-30
@@ -1,29 +1,21 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import EANReader from './ean_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
function UPCEReader() {
|
||||||
[
|
|
||||||
"./ean_reader"
|
|
||||||
],
|
|
||||||
function(EANReader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function UPCEReader() {
|
|
||||||
EANReader.call(this);
|
EANReader.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
CODE_FREQUENCY : {value: [
|
CODE_FREQUENCY : {value: [
|
||||||
[ 56, 52, 50, 49, 44, 38, 35, 42, 41, 37 ],
|
[ 56, 52, 50, 49, 44, 38, 35, 42, 41, 37 ],
|
||||||
[7, 11, 13, 14, 19, 25, 28, 21, 22, 26]]},
|
[7, 11, 13, 14, 19, 25, 28, 21, 22, 26]]},
|
||||||
STOP_PATTERN: { value: [1 / 6 * 7, 1 / 6 * 7, 1 / 6 * 7, 1 / 6 * 7, 1 / 6 * 7, 1 / 6 * 7]},
|
STOP_PATTERN: { value: [1 / 6 * 7, 1 / 6 * 7, 1 / 6 * 7, 1 / 6 * 7, 1 / 6 * 7, 1 / 6 * 7]},
|
||||||
FORMAT: {value: "upc_e", writeable: false}
|
FORMAT: {value: "upc_e", writeable: false}
|
||||||
};
|
};
|
||||||
|
|
||||||
UPCEReader.prototype = Object.create(EANReader.prototype, properties);
|
UPCEReader.prototype = Object.create(EANReader.prototype, properties);
|
||||||
UPCEReader.prototype.constructor = UPCEReader;
|
UPCEReader.prototype.constructor = UPCEReader;
|
||||||
|
|
||||||
UPCEReader.prototype._decodePayload = function(code, result, decodedCodes) {
|
UPCEReader.prototype._decodePayload = function(code, result, decodedCodes) {
|
||||||
var i,
|
var i,
|
||||||
self = this,
|
self = this,
|
||||||
codeFrequency = 0x0;
|
codeFrequency = 0x0;
|
||||||
@@ -45,9 +37,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
UPCEReader.prototype._determineParity = function(codeFrequency, result) {
|
UPCEReader.prototype._determineParity = function(codeFrequency, result) {
|
||||||
var self =this,
|
var self =this,
|
||||||
i,
|
i,
|
||||||
nrSystem;
|
nrSystem;
|
||||||
@@ -62,9 +54,9 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
UPCEReader.prototype._convertToUPCA = function(result) {
|
UPCEReader.prototype._convertToUPCA = function(result) {
|
||||||
var upca = [result[0]],
|
var upca = [result[0]],
|
||||||
lastDigit = result[result.length - 2];
|
lastDigit = result[result.length - 2];
|
||||||
|
|
||||||
@@ -86,18 +78,18 @@ define(
|
|||||||
|
|
||||||
upca.push(result[result.length - 1]);
|
upca.push(result[result.length - 1]);
|
||||||
return upca;
|
return upca;
|
||||||
};
|
};
|
||||||
|
|
||||||
UPCEReader.prototype._checksum = function(result) {
|
UPCEReader.prototype._checksum = function(result) {
|
||||||
return EANReader.prototype._checksum.call(this, this._convertToUPCA(result));
|
return EANReader.prototype._checksum.call(this, this._convertToUPCA(result));
|
||||||
};
|
};
|
||||||
|
|
||||||
UPCEReader.prototype._findEnd = function(offset, isWhite) {
|
UPCEReader.prototype._findEnd = function(offset, isWhite) {
|
||||||
isWhite = true;
|
isWhite = true;
|
||||||
return EANReader.prototype._findEnd.call(this, offset, isWhite);
|
return EANReader.prototype._findEnd.call(this, offset, isWhite);
|
||||||
};
|
};
|
||||||
|
|
||||||
UPCEReader.prototype._verifyTrailingWhitespace = function(endInfo) {
|
UPCEReader.prototype._verifyTrailingWhitespace = function(endInfo) {
|
||||||
var self = this,
|
var self = this,
|
||||||
trailingWhitespaceEnd;
|
trailingWhitespaceEnd;
|
||||||
|
|
||||||
@@ -107,8 +99,6 @@ define(
|
|||||||
return endInfo;
|
return endInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (UPCEReader);
|
export default UPCEReader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+10
-20
@@ -1,25 +1,17 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import EANReader from './ean_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
function UPCReader() {
|
||||||
[
|
|
||||||
"./ean_reader"
|
|
||||||
],
|
|
||||||
function(EANReader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function UPCReader() {
|
|
||||||
EANReader.call(this);
|
EANReader.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
FORMAT: {value: "upc_a", writeable: false}
|
FORMAT: {value: "upc_a", writeable: false}
|
||||||
};
|
};
|
||||||
|
|
||||||
UPCReader.prototype = Object.create(EANReader.prototype, properties);
|
UPCReader.prototype = Object.create(EANReader.prototype, properties);
|
||||||
UPCReader.prototype.constructor = UPCReader;
|
UPCReader.prototype.constructor = UPCReader;
|
||||||
|
|
||||||
UPCReader.prototype._decode = function() {
|
UPCReader.prototype._decode = function() {
|
||||||
var result = EANReader.prototype._decode.call(this);
|
var result = EANReader.prototype._decode.call(this);
|
||||||
|
|
||||||
if (result && result.code && result.code.length === 13 && result.code.charAt(0) === "0") {
|
if (result && result.code && result.code.length === 13 && result.code.charAt(0) === "0") {
|
||||||
@@ -28,8 +20,6 @@ define(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (UPCReader);
|
export default EANReader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
var webpack = require('webpack'),
|
||||||
|
MyUmdPlugin = require('./plugins/umd');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: [
|
||||||
|
'./src/quagga.js'
|
||||||
|
],
|
||||||
|
devtool: 'source-map',
|
||||||
|
module: {
|
||||||
|
loaders: [{
|
||||||
|
test: /\.jsx?$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
loader: 'babel'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['', '.js', '.jsx']
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
path: __dirname + '/dist',
|
||||||
|
publicPath: '/',
|
||||||
|
filename: 'quagga.js',
|
||||||
|
sourceMapFilename: 'quagga.map'
|
||||||
|
},
|
||||||
|
devServer: {
|
||||||
|
contentBase: './',
|
||||||
|
hot: true
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new MyUmdPlugin({
|
||||||
|
library: 'Quagga'
|
||||||
|
})
|
||||||
|
]
|
||||||
|
};
|
||||||
Vendored
+8
@@ -0,0 +1,8 @@
|
|||||||
|
var webpack = require('webpack');
|
||||||
|
module.exports = require('./webpack.config.js');
|
||||||
|
|
||||||
|
module.exports.plugins.unshift(
|
||||||
|
new webpack.optimize.UglifyJsPlugin()
|
||||||
|
);
|
||||||
|
|
||||||
|
module.exports.output.filename = 'quagga.min.js';
|
||||||
Reference in New Issue
Block a user