|
|
|
@ -6589,7 +6589,9 @@ define(
|
|
|
|
|
return counter;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Code39Reader.prototype._decode = function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code39Reader.prototype._decodeToResult = function() {
|
|
|
|
|
var self = this,
|
|
|
|
|
counters = [0,0,0,0,0,0,0,0,0],
|
|
|
|
|
result = [],
|
|
|
|
@ -6599,6 +6601,7 @@ define(
|
|
|
|
|
pattern,
|
|
|
|
|
nextStart;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!start) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
@ -6621,8 +6624,6 @@ define(
|
|
|
|
|
} while(decodedChar !== '*');
|
|
|
|
|
result.pop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
code : result.join(""),
|
|
|
|
|
start : start.start,
|
|
|
|
@ -6632,6 +6633,10 @@ define(
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Code39Reader.prototype._decode = function() {
|
|
|
|
|
return this._decodeToResult();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Code39Reader.prototype._patternToChar = function(pattern) {
|
|
|
|
|
var i,
|
|
|
|
|
self = this;
|
|
|
|
@ -6740,6 +6745,67 @@ define(
|
|
|
|
|
return (Code39Reader);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* jshint undef: true, unused: true, browser:true, devel: true */
|
|
|
|
|
/* global define */
|
|
|
|
|
|
|
|
|
|
define(
|
|
|
|
|
'code_39_vin_reader',[
|
|
|
|
|
"./code_39_reader"
|
|
|
|
|
],
|
|
|
|
|
function(Code39Reader) {
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
function Code39VINReader() {
|
|
|
|
|
Code39Reader.call(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var patterns = {
|
|
|
|
|
IOQ: /[IOQ]/g,
|
|
|
|
|
AZ09: /[A-Z0-9]{17}/
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Code39VINReader.prototype = Object.create(Code39Reader.prototype);
|
|
|
|
|
Code39VINReader.prototype.constructor = Code39VINReader;
|
|
|
|
|
|
|
|
|
|
// Cribbed from:
|
|
|
|
|
// https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/client/result/VINResultParser.java
|
|
|
|
|
Code39VINReader.prototype._decode = function() {
|
|
|
|
|
var result = this._decodeToResult();
|
|
|
|
|
if (!result) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var code = result.code;
|
|
|
|
|
|
|
|
|
|
if (!code) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
code = code.replace(patterns.IOQ, '');
|
|
|
|
|
|
|
|
|
|
if (!code.match(patterns.AZ09)) {
|
|
|
|
|
console.log('Failed AZ09 pattern code:', code);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this._checkChecksum(code)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.code = code;
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Code39VINReader.prototype._checkChecksum = function(code) {
|
|
|
|
|
// TODO
|
|
|
|
|
return !!code;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (Code39VINReader);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/* jshint undef: true, unused: true, browser:true, devel: true */
|
|
|
|
|
/* global define */
|
|
|
|
|
|
|
|
|
@ -7247,6 +7313,7 @@ define('barcode_decoder',[
|
|
|
|
|
'code_128_reader',
|
|
|
|
|
'ean_reader',
|
|
|
|
|
'code_39_reader',
|
|
|
|
|
'code_39_vin_reader',
|
|
|
|
|
'codabar_reader',
|
|
|
|
|
'upc_reader',
|
|
|
|
|
'ean_8_reader',
|
|
|
|
@ -7257,17 +7324,19 @@ define('barcode_decoder',[
|
|
|
|
|
Code128Reader,
|
|
|
|
|
EANReader,
|
|
|
|
|
Code39Reader,
|
|
|
|
|
Code39VINReader,
|
|
|
|
|
CodabarReader,
|
|
|
|
|
UPCReader,
|
|
|
|
|
EAN8Reader,
|
|
|
|
|
UPCEReader) {
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var readers = {
|
|
|
|
|
code_128_reader: Code128Reader,
|
|
|
|
|
ean_reader: EANReader,
|
|
|
|
|
ean_8_reader: EAN8Reader,
|
|
|
|
|
code_39_reader: Code39Reader,
|
|
|
|
|
code_39_vin_reader: Code39VINReader,
|
|
|
|
|
codabar_reader: CodabarReader,
|
|
|
|
|
upc_reader: UPCReader,
|
|
|
|
|
upc_e_reader: UPCEReader
|
|
|
|
@ -7288,7 +7357,7 @@ define('barcode_decoder',[
|
|
|
|
|
},
|
|
|
|
|
_barcodeReaders = [],
|
|
|
|
|
_barcodeReader = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initCanvas();
|
|
|
|
|
initReaders();
|
|
|
|
|
initConfig();
|
|
|
|
@ -7353,9 +7422,9 @@ define('barcode_decoder',[
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* extend the line on both ends
|
|
|
|
|
* extend the line on both ends
|
|
|
|
|
* @param {Array} line
|
|
|
|
|
* @param {Number} angle
|
|
|
|
|
* @param {Number} angle
|
|
|
|
|
*/
|
|
|
|
|
function getExtendedLine(line, angle, ext) {
|
|
|
|
|
function extendLine(amount) {
|
|
|
|
@ -7381,7 +7450,7 @@ define('barcode_decoder',[
|
|
|
|
|
}
|
|
|
|
|
return line;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getLine(box) {
|
|
|
|
|
return [{
|
|
|
|
|
x : (box[1][0] - box[0][0]) / 2 + box[0][0],
|
|
|
|
@ -7391,12 +7460,12 @@ define('barcode_decoder',[
|
|
|
|
|
y : (box[3][1] - box[2][1]) / 2 + box[2][1]
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function tryDecode(line) {
|
|
|
|
|
var result = null,
|
|
|
|
|
i,
|
|
|
|
|
barcodeLine = Bresenham.getBarcodeLine(inputImageWrapper, line[0], line[1]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (config.showFrequency) {
|
|
|
|
|
ImageDebug.drawPath(line, {x: 'x', y: 'y'}, _canvas.ctx.overlay, {color: 'red', lineWidth: 3});
|
|
|
|
|
Bresenham.debug.printFrequency(barcodeLine.line, _canvas.dom.frequency);
|
|
|
|
@ -7405,7 +7474,7 @@ define('barcode_decoder',[
|
|
|
|
|
if (config.showPattern) {
|
|
|
|
|
Bresenham.debug.printPattern(barcodeLine.line, _canvas.dom.pattern);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( i = 0; i < _barcodeReaders.length && result === null; i++) {
|
|
|
|
|
result = _barcodeReaders[i].decodePattern(barcodeLine.line);
|
|
|
|
|
if (result !== null) {
|
|
|
|
@ -7419,15 +7488,15 @@ define('barcode_decoder',[
|
|
|
|
|
codeResult: result,
|
|
|
|
|
barcodeLine: barcodeLine
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This method slices the given area apart and tries to detect a barcode-pattern
|
|
|
|
|
* for each slice. It returns the decoded barcode, or null if nothing was found
|
|
|
|
|
* @param {Array} box
|
|
|
|
|
* @param {Array} line
|
|
|
|
|
* @param {Number} lineAngle
|
|
|
|
|
* @param {Number} lineAngle
|
|
|
|
|
*/
|
|
|
|
|
function tryDecodeBruteForce(box, line, lineAngle) {
|
|
|
|
|
var sideLength = Math.sqrt(Math.pow(box[1][0] - box[0][0], 2) + Math.pow((box[1][1] - box[0][1]), 2)),
|
|
|
|
@ -7438,7 +7507,7 @@ define('barcode_decoder',[
|
|
|
|
|
extension,
|
|
|
|
|
xdir = Math.sin(lineAngle),
|
|
|
|
|
ydir = Math.cos(lineAngle);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( i = 1; i < slices && result === null; i++) {
|
|
|
|
|
// move line perpendicular to angle
|
|
|
|
|
dir = sideLength / slices * i * (i % 2 === 0 ? -1 : 1);
|
|
|
|
@ -7463,7 +7532,7 @@ define('barcode_decoder',[
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* With the help of the configured readers (Code128 or EAN) this function tries to detect a
|
|
|
|
|
* With the help of the configured readers (Code128 or EAN) this function tries to detect a
|
|
|
|
|
* valid barcode pattern within the given area.
|
|
|
|
|
* @param {Object} box The area to search in
|
|
|
|
|
* @returns {Object} the result {codeResult, line, angle, pattern, threshold}
|
|
|
|
@ -7491,7 +7560,7 @@ define('barcode_decoder',[
|
|
|
|
|
if(result === null) {
|
|
|
|
|
result = tryDecodeBruteForce(box, line, lineAngle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(result === null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
@ -7533,7 +7602,8 @@ define('barcode_decoder',[
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (BarcodeDecoder);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* jshint undef: true, unused: true, browser:true, devel: true */
|
|
|
|
|
/* global define */
|
|
|
|
|
|
|
|
|
@ -7668,7 +7738,7 @@ define('html_utils',[], function() {
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
/**
|
|
|
|
|
* The basic configuration
|
|
|
|
|
* The basic configuration
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
define('config',[],function(){
|
|
|
|
@ -7678,6 +7748,8 @@ define('config',[],function(){
|
|
|
|
|
constraints: {
|
|
|
|
|
width: 640,
|
|
|
|
|
height: 480,
|
|
|
|
|
minAspectRatio: 1,
|
|
|
|
|
maxAspectRatio: 1,
|
|
|
|
|
facing: "environment" // or user
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
@ -7715,9 +7787,10 @@ define('config',[],function(){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* jshint undef: true, unused: true, browser:true, devel: true */
|
|
|
|
|
/* global define */
|
|
|
|
|
|
|
|
|
@ -7816,7 +7889,7 @@ define('camera_access',["html_utils"], function(HtmlUtils) {
|
|
|
|
|
"use strict";
|
|
|
|
|
var streamRef,
|
|
|
|
|
loadedDataHandler;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Wraps browser-specific getUserMedia
|
|
|
|
|
* @param {Object} constraints
|
|
|
|
@ -7885,6 +7958,8 @@ define('camera_access',["html_utils"], function(HtmlUtils) {
|
|
|
|
|
videoConstraints = HtmlUtils.mergeObjects({
|
|
|
|
|
width: 640,
|
|
|
|
|
height: 480,
|
|
|
|
|
minAspectRatio: 1,
|
|
|
|
|
maxAspectRatio: 1,
|
|
|
|
|
facing: "environment"
|
|
|
|
|
}, config);
|
|
|
|
|
|
|
|
|
@ -7900,7 +7975,9 @@ define('camera_access',["html_utils"], function(HtmlUtils) {
|
|
|
|
|
constraints.video = {
|
|
|
|
|
mandatory: {
|
|
|
|
|
minWidth: videoConstraints.width,
|
|
|
|
|
minHeight: videoConstraints.height
|
|
|
|
|
minHeight: videoConstraints.height,
|
|
|
|
|
minAspectRatio: videoConstraints.minAspectRatio,
|
|
|
|
|
maxAspectRatio: videoConstraints.maxAspectRatio
|
|
|
|
|
},
|
|
|
|
|
optional: [{
|
|
|
|
|
sourceId: videoSourceId
|
|
|
|
@ -7943,7 +8020,8 @@ define('camera_access',["html_utils"], function(HtmlUtils) {
|
|
|
|
|
streamRef = null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* jshint undef: true, unused: true, browser:true, devel: true, evil: true */
|
|
|
|
|
/* global define, vec2 */
|
|
|
|
|
|
|
|
|
|