mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-12 21:21:42 +08:00
Fixed EAN-readers
This commit is contained in:
@@ -168,7 +168,7 @@ Code128Reader.prototype._decodeCode = function(start, correction) {
|
||||
}
|
||||
}
|
||||
bestMatch.end = i;
|
||||
if (bestMatch.code === -1) {
|
||||
if (bestMatch.code === -1 || bestMatch.error > self.AVG_CODE_ERROR) {
|
||||
return null;
|
||||
}
|
||||
if (self.CODE_PATTERN[bestMatch.code]) {
|
||||
@@ -241,9 +241,11 @@ Code128Reader.prototype._findStart = function() {
|
||||
bestMatch.start = i - sum;
|
||||
bestMatch.end = i;
|
||||
bestMatch.correction.bar = calculateCorrection(
|
||||
self.CODE_PATTERN[code], normalized, [0, 2, 4]);
|
||||
self.CODE_PATTERN[bestMatch.code], normalized,
|
||||
this.MODULE_INDICES.bar);
|
||||
bestMatch.correction.space = calculateCorrection(
|
||||
self.CODE_PATTERN[code], normalized, [1, 3, 5]);
|
||||
self.CODE_PATTERN[bestMatch.code], normalized,
|
||||
this.MODULE_INDICES.space);
|
||||
return bestMatch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ EAN2Reader.prototype.decode = function(row, start) {
|
||||
}
|
||||
}
|
||||
|
||||
if (result.length != 2 || (result.reduce((sum, i) => sum + i, 0) % 4 !== codeFrequency)) {
|
||||
if (result.length != 2 || (parseInt(result.join("")) % 4) !== codeFrequency) {
|
||||
return null;
|
||||
}
|
||||
console.log(result);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import EANReader from './ean_reader';
|
||||
|
||||
function EAN8Reader() {
|
||||
EANReader.call(this);
|
||||
function EAN8Reader(opts, supplements) {
|
||||
EANReader.call(this, opts, supplements);
|
||||
}
|
||||
|
||||
var properties = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import EANReader from './ean_reader';
|
||||
|
||||
function UPCEReader() {
|
||||
EANReader.call(this);
|
||||
function UPCEReader(opts, supplements) {
|
||||
EANReader.call(this, opts, supplements);
|
||||
}
|
||||
|
||||
var properties = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import EANReader from './ean_reader';
|
||||
|
||||
function UPCReader() {
|
||||
EANReader.call(this);
|
||||
function UPCReader(opts, supplements) {
|
||||
EANReader.call(this, opts, supplements);
|
||||
}
|
||||
|
||||
var properties = {
|
||||
|
||||
Reference in New Issue
Block a user