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
+9541
-3537
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));
|
||||||
|
};
|
||||||
+1
-8
@@ -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--) {
|
||||||
@@ -83,4 +77,3 @@ define(function() {
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
|
||||||
+12
-32
@@ -1,31 +1,14 @@
|
|||||||
/* 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';
|
||||||
define([
|
import EANReader from './ean_reader';
|
||||||
"bresenham",
|
import Code39Reader from './code_39_reader';
|
||||||
"image_debug",
|
import Code39VINReader from './code_39_vin_reader';
|
||||||
'code_128_reader',
|
import CodabarReader from './codabar_reader';
|
||||||
'ean_reader',
|
import UPCReader from './upc_reader';
|
||||||
'code_39_reader',
|
import EAN8Reader from './ean_8_reader';
|
||||||
'code_39_vin_reader',
|
import UPCEReader from './upc_e_reader';
|
||||||
'codabar_reader',
|
import I2of5Reader from './i2of5_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 = {
|
var readers = {
|
||||||
code_128_reader: Code128Reader,
|
code_128_reader: Code128Reader,
|
||||||
@@ -38,7 +21,7 @@ define([
|
|||||||
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 : {
|
||||||
@@ -300,6 +283,3 @@ define([
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (BarcodeDecoder);
|
|
||||||
});
|
|
||||||
|
|||||||
+10
-6
@@ -1,8 +1,14 @@
|
|||||||
/* 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,
|
||||||
@@ -27,7 +33,7 @@ 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;
|
||||||
@@ -479,7 +485,7 @@ 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;
|
||||||
@@ -557,5 +563,3 @@ function(ImageWrapper, CVUtils, Rasterizer, Tracer, skeletonizer, ArrayHelper, I
|
|||||||
") must a multiple of " + patchSize.x);
|
") must a multiple of " + patchSize.x);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|
||||||
|
|||||||
+1
-10
@@ -1,10 +1,3 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
|
||||||
function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function BarcodeReader(config) {
|
function BarcodeReader(config) {
|
||||||
this._row = [];
|
this._row = [];
|
||||||
this.config = config || {};
|
this.config = config || {};
|
||||||
@@ -226,6 +219,4 @@ define(
|
|||||||
|
|
||||||
BarcodeReader.CONFIG_KEYS = {};
|
BarcodeReader.CONFIG_KEYS = {};
|
||||||
|
|
||||||
return (BarcodeReader);
|
export default BarcodeReader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+3
-6
@@ -1,8 +1,6 @@
|
|||||||
/* 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) {
|
|
||||||
"use strict";
|
|
||||||
var Bresenham = {};
|
var Bresenham = {};
|
||||||
|
|
||||||
var Slope = {
|
var Slope = {
|
||||||
@@ -213,5 +211,4 @@ define(["cv_utils", "image_wrapper"], function(CVUtils, ImageWrapper) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Bresenham);
|
export default Bresenham;
|
||||||
});
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
const merge = require('lodash/object/merge');
|
||||||
/* global define, MediaStreamTrack */
|
|
||||||
|
|
||||||
define(["html_utils"], function(HtmlUtils) {
|
|
||||||
"use strict";
|
|
||||||
var streamRef,
|
var streamRef,
|
||||||
loadedDataHandler;
|
loadedDataHandler;
|
||||||
|
|
||||||
@@ -75,7 +72,7 @@ define(["html_utils"], function(HtmlUtils) {
|
|||||||
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,
|
||||||
@@ -128,7 +125,7 @@ define(["html_utils"], function(HtmlUtils) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
export default {
|
||||||
request : function(video, constraints, callback) {
|
request : function(video, constraints, callback) {
|
||||||
request(video, constraints, callback);
|
request(video, constraints, callback);
|
||||||
},
|
},
|
||||||
@@ -140,4 +137,3 @@ define(["html_utils"], function(HtmlUtils) {
|
|||||||
streamRef = null;
|
streamRef = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|||||||
+2
-11
@@ -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,
|
||||||
@@ -67,6 +61,3 @@ define(["gl-matrix"], function(glMatrix) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Cluster);
|
|
||||||
});
|
|
||||||
|
|||||||
+2
-12
@@ -1,12 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import BarcodeReader from './barcode_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
|
||||||
[
|
|
||||||
"./barcode_reader"
|
|
||||||
],
|
|
||||||
function(BarcodeReader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function CodabarReader() {
|
function CodabarReader() {
|
||||||
BarcodeReader.call(this);
|
BarcodeReader.call(this);
|
||||||
@@ -289,6 +281,4 @@ define(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (CodabarReader);
|
export default CodabarReader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+2
-12
@@ -1,12 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import BarcodeReader from './barcode_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
|
||||||
[
|
|
||||||
"./barcode_reader"
|
|
||||||
],
|
|
||||||
function(BarcodeReader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function Code128Reader() {
|
function Code128Reader() {
|
||||||
BarcodeReader.call(this);
|
BarcodeReader.call(this);
|
||||||
@@ -418,6 +410,4 @@ define(
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Code128Reader);
|
export default Code128Reader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+3
-13
@@ -1,13 +1,5 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import BarcodeReader from './barcode_reader';
|
||||||
/* global define */
|
import ArrayHelper from './array_helper';
|
||||||
|
|
||||||
define(
|
|
||||||
[
|
|
||||||
"./barcode_reader",
|
|
||||||
"./array_helper"
|
|
||||||
],
|
|
||||||
function(BarcodeReader, ArrayHelper) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function Code39Reader() {
|
function Code39Reader() {
|
||||||
BarcodeReader.call(this);
|
BarcodeReader.call(this);
|
||||||
@@ -216,6 +208,4 @@ define(
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Code39Reader);
|
export default Code39Reader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
@@ -1,12 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import Code39Reader from './code_39_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
|
||||||
[
|
|
||||||
"./code_39_reader"
|
|
||||||
],
|
|
||||||
function(Code39Reader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function Code39VINReader() {
|
function Code39VINReader() {
|
||||||
Code39Reader.call(this);
|
Code39Reader.call(this);
|
||||||
@@ -54,6 +46,4 @@ define(
|
|||||||
return !!code;
|
return !!code;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Code39VINReader);
|
export default Code39VINReader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+3
-10
@@ -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,
|
||||||
@@ -55,6 +51,3 @@ define(function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return config;
|
|
||||||
});
|
|
||||||
|
|||||||
+5
-21
@@ -1,22 +1,8 @@
|
|||||||
/* 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
|
||||||
@@ -714,6 +700,4 @@ define(['cluster', "array_helper", "gl-matrix"], function(Cluster2, ArrayHelper,
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
return (CVUtils);
|
export default CVUtils;
|
||||||
});
|
|
||||||
|
|
||||||
|
|||||||
+2
-12
@@ -1,12 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import EANReader from './ean_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
|
||||||
[
|
|
||||||
"./ean_reader"
|
|
||||||
],
|
|
||||||
function(EANReader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function EAN8Reader() {
|
function EAN8Reader() {
|
||||||
EANReader.call(this);
|
EANReader.call(this);
|
||||||
@@ -50,6 +42,4 @@ define(
|
|||||||
return code;
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (EAN8Reader);
|
export default EAN8Reader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+2
-12
@@ -1,12 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import BarcodeReader from './barcode_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
|
||||||
[
|
|
||||||
"./barcode_reader"
|
|
||||||
],
|
|
||||||
function(BarcodeReader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function EANReader(opts) {
|
function EANReader(opts) {
|
||||||
BarcodeReader.call(this, opts);
|
BarcodeReader.call(this, opts);
|
||||||
@@ -332,6 +324,4 @@ define(
|
|||||||
return sum % 10 === 0;
|
return sum % 10 === 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (EANReader);
|
export default (EANReader);
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+1
-10
@@ -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) {
|
||||||
@@ -86,6 +80,3 @@ define(function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}();
|
}();
|
||||||
|
|
||||||
return _events;
|
|
||||||
});
|
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import CVUtils from './cv_utils';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(["cv_utils"], function(CVUtils) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var FrameGrabber = {};
|
var FrameGrabber = {};
|
||||||
|
|
||||||
@@ -74,5 +70,4 @@ 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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
+4
-14
@@ -1,16 +1,8 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import BarcodeReader from './barcode_reader';
|
||||||
/* global define */
|
const merge = require('lodash/object/merge');
|
||||||
|
|
||||||
define(
|
|
||||||
[
|
|
||||||
"./barcode_reader",
|
|
||||||
"./html_utils"
|
|
||||||
],
|
|
||||||
function(BarcodeReader, HTMLUtils) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function I2of5Reader(opts) {
|
function I2of5Reader(opts) {
|
||||||
opts = HTMLUtils.mergeObjects(getDefaulConfig(), opts);
|
opts = merge(getDefaulConfig(), opts);
|
||||||
BarcodeReader.call(this, opts);
|
BarcodeReader.call(this, opts);
|
||||||
this.barSpaceRatio = [1, 1];
|
this.barSpaceRatio = [1, 1];
|
||||||
if (opts.normalizeBarSpaceWidth) {
|
if (opts.normalizeBarSpaceWidth) {
|
||||||
@@ -339,6 +331,4 @@ define(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (I2of5Reader);
|
export default I2of5Reader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+1
-9
@@ -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;
|
||||||
@@ -45,5 +39,3 @@ define(function() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
|
||||||
|
|||||||
+1
-8
@@ -1,9 +1,3 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var ImageLoader = {};
|
var ImageLoader = {};
|
||||||
ImageLoader.load = function(directory, callback, offset, size, sequence) {
|
ImageLoader.load = function(directory, callback, offset, size, sequence) {
|
||||||
var htmlImagesSrcArray = new Array(size),
|
var htmlImagesSrcArray = new Array(size),
|
||||||
@@ -59,5 +53,4 @@ define(function() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ImageLoader);
|
export default (ImageLoader);
|
||||||
});
|
|
||||||
|
|||||||
+5
-16
@@ -1,17 +1,7 @@
|
|||||||
/* 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';
|
||||||
define([
|
import {vec2, mat2} from 'gl-matrix';
|
||||||
"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.
|
||||||
@@ -423,5 +413,4 @@ define([
|
|||||||
ctx.putImageData(frame, from.x, from.y);
|
ctx.putImageData(frame, from.x, from.y);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (ImageWrapper);
|
export default ImageWrapper;
|
||||||
});
|
|
||||||
|
|||||||
+2
-7
@@ -1,8 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import ImageLoader from './image_loader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(["image_loader"], function(ImageLoader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var InputStream = {};
|
var InputStream = {};
|
||||||
InputStream.createVideoStream = function(video) {
|
InputStream.createVideoStream = function(video) {
|
||||||
@@ -313,5 +309,4 @@ define(["image_loader"], function(ImageLoader) {
|
|||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (InputStream);
|
export default InputStream;
|
||||||
});
|
|
||||||
|
|||||||
+20
-34
@@ -1,31 +1,17 @@
|
|||||||
/* 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",
|
const merge = require('lodash/object/merge');
|
||||||
"result_collector"],
|
|
||||||
function(InputStream,
|
|
||||||
ImageWrapper,
|
|
||||||
BarcodeLocator,
|
|
||||||
BarcodeDecoder,
|
|
||||||
FrameGrabber,
|
|
||||||
HtmlUtils,
|
|
||||||
_config,
|
|
||||||
Events,
|
|
||||||
CameraAccess,
|
|
||||||
ImageDebug,
|
|
||||||
glMatrix,
|
|
||||||
ResultCollector) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var _inputStream,
|
var _inputStream,
|
||||||
_framegrabber,
|
_framegrabber,
|
||||||
@@ -45,8 +31,8 @@ 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);
|
||||||
@@ -360,6 +346,7 @@ function(InputStream,
|
|||||||
|
|
||||||
|
|
||||||
function workerInterface(factory) {
|
function workerInterface(factory) {
|
||||||
|
window = self;
|
||||||
if (factory) {
|
if (factory) {
|
||||||
/* jshint ignore:start */
|
/* jshint ignore:start */
|
||||||
var Quagga = factory();
|
var Quagga = factory();
|
||||||
@@ -426,9 +413,9 @@ function(InputStream,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
@@ -501,4 +488,3 @@ function(InputStream,
|
|||||||
ImageDebug: ImageDebug,
|
ImageDebug: ImageDebug,
|
||||||
ResultCollector: ResultCollector
|
ResultCollector: ResultCollector
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|||||||
+2
-7
@@ -1,12 +1,8 @@
|
|||||||
/* 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) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var Rasterizer = {
|
var Rasterizer = {
|
||||||
createContour2D : function() {
|
createContour2D : function() {
|
||||||
return {
|
return {
|
||||||
@@ -194,5 +190,4 @@ define(["tracer"], function(Tracer) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Rasterizer);
|
export default Rasterizer;
|
||||||
});
|
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import ImageDebug from './image_debug';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(["image_debug"], function(ImageDebug) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function contains(codeResult, list) {
|
function contains(codeResult, list) {
|
||||||
if (list) {
|
if (list) {
|
||||||
@@ -22,7 +18,7 @@ define(["image_debug"], function(ImageDebug) {
|
|||||||
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"),
|
||||||
@@ -56,4 +52,3 @@ define(["image_debug"], function(ImageDebug) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|||||||
+1
-8
@@ -1,9 +1,3 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true, -W041: false */
|
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(function() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/* @preserve ASM BEGIN */
|
/* @preserve ASM BEGIN */
|
||||||
function Skeletonizer(stdlib, foreign, buffer) {
|
function Skeletonizer(stdlib, foreign, buffer) {
|
||||||
"use asm";
|
"use asm";
|
||||||
@@ -200,5 +194,4 @@ define(function() {
|
|||||||
}
|
}
|
||||||
/* @preserve ASM END */
|
/* @preserve ASM END */
|
||||||
|
|
||||||
return Skeletonizer;
|
export default Skeletonizer;
|
||||||
});
|
|
||||||
|
|||||||
+1
-8
@@ -1,9 +1,3 @@
|
|||||||
/* 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.
|
||||||
@@ -93,5 +87,4 @@ define(["typedefs"], function() {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (SubImage);
|
export default (SubImage);
|
||||||
});
|
|
||||||
|
|||||||
+1
-8
@@ -1,12 +1,6 @@
|
|||||||
/* 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() {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var Tracer = {
|
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) {
|
||||||
@@ -104,5 +98,4 @@ define(function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (Tracer);
|
export default (Tracer);
|
||||||
});
|
|
||||||
|
|||||||
+4
-1
@@ -3,7 +3,6 @@
|
|||||||
* 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 ||
|
||||||
@@ -28,3 +27,7 @@ Math.imul = Math.imul || function(a, b) {
|
|||||||
// 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 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
+2
-12
@@ -1,12 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import EANReader from './ean_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
|
||||||
[
|
|
||||||
"./ean_reader"
|
|
||||||
],
|
|
||||||
function(EANReader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function UPCEReader() {
|
function UPCEReader() {
|
||||||
EANReader.call(this);
|
EANReader.call(this);
|
||||||
@@ -109,6 +101,4 @@ define(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (UPCEReader);
|
export default UPCEReader;
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|||||||
+2
-12
@@ -1,12 +1,4 @@
|
|||||||
/* jshint undef: true, unused: true, browser:true, devel: true */
|
import EANReader from './ean_reader';
|
||||||
/* global define */
|
|
||||||
|
|
||||||
define(
|
|
||||||
[
|
|
||||||
"./ean_reader"
|
|
||||||
],
|
|
||||||
function(EANReader) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function UPCReader() {
|
function UPCReader() {
|
||||||
EANReader.call(this);
|
EANReader.call(this);
|
||||||
@@ -30,6 +22,4 @@ define(
|
|||||||
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