Comparing version 0.6.8 to 0.6.9
@@ -37,2 +37,3 @@ module.exports = function(grunt) { | ||
"name" : "quagga", | ||
"useStrict": false, | ||
"out" : "dist/quagga.js", | ||
@@ -39,0 +40,0 @@ "include" : ['quagga'], |
{ | ||
"name": "quagga", | ||
"version": "0.6.8", | ||
"version": "0.6.9", | ||
"description": "An advanced barcode-scanner written in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/quagga.js", |
quaggaJS | ||
======== | ||
- [Changelog](#changelog) (2015-06-13) | ||
- [Changelog](#changelog) (2015-06-14) | ||
@@ -146,3 +146,4 @@ ## What is QuaggaJS? | ||
"codeResult": { | ||
"code": "FANAVF1461710", | ||
"code": "FANAVF1461710", // the decoded code as a string | ||
"format": "code_128", // or code_39, codabar, ean_13, ean_8, upc_a, upc_e | ||
"start": 355, | ||
@@ -305,2 +306,6 @@ "end": 26, | ||
- Improvements | ||
- Added ``format`` property to ``codeResult`` (in [result](#resultobject)) | ||
### 2015-06-13 | ||
- Improvements | ||
- Added fixes for ``Code39Reader`` (trailing whitespace was missing) | ||
@@ -307,0 +312,0 @@ |
@@ -38,2 +38,3 @@ | ||
expect(result.codeResult.code).to.equal(sample.result); | ||
expect(result.codeResult.format).to.equal(sample.format); | ||
callback(); | ||
@@ -49,15 +50,19 @@ }); | ||
var config = generateConfig(), | ||
testSet = [ | ||
{"name": "image-001.jpg", "result": "3574660239843"}, | ||
{"name": "image-002.jpg", "result": "8032754490297"}, | ||
{"name": "image-003.jpg", "result": "4006209700068"}, | ||
/* {"name": "image-004.jpg", "result": "9002233139084"}, */ | ||
/* {"name": "image-005.jpg", "result": "8004030044005"}, */ | ||
{"name": "image-006.jpg", "result": "4003626011159"}, | ||
{"name": "image-007.jpg", "result": "2111220009686"}, | ||
{"name": "image-008.jpg", "result": "9000275609022"}, | ||
{"name": "image-009.jpg", "result": "9004593978587"}, | ||
{"name": "image-010.jpg", "result": "9002244845578"} | ||
]; | ||
testSet = [ | ||
{"name": "image-001.jpg", "result": "3574660239843"}, | ||
{"name": "image-002.jpg", "result": "8032754490297"}, | ||
{"name": "image-003.jpg", "result": "4006209700068"}, | ||
/* {"name": "image-004.jpg", "result": "9002233139084"}, */ | ||
/* {"name": "image-005.jpg", "result": "8004030044005"}, */ | ||
{"name": "image-006.jpg", "result": "4003626011159"}, | ||
{"name": "image-007.jpg", "result": "2111220009686"}, | ||
{"name": "image-008.jpg", "result": "9000275609022"}, | ||
{"name": "image-009.jpg", "result": "9004593978587"}, | ||
{"name": "image-010.jpg", "result": "9002244845578"} | ||
]; | ||
testSet.forEach(function(sample) { | ||
sample.format = "ean_13"; | ||
}); | ||
config.decoder.readers = ['ean_reader']; | ||
@@ -70,14 +75,18 @@ _runTestSet(testSet, config); | ||
testSet = [ | ||
{"name": "image-001.jpg", "result": "0001285112001000040801"}, | ||
{"name": "image-002.jpg", "result": "FANAVF1461710"}, | ||
{"name": "image-003.jpg", "result": "673023"}, | ||
// {"name": "image-004.jpg", "result": "010210150301625334"}, | ||
{"name": "image-005.jpg", "result": "419055603900009001012999"}, | ||
{"name": "image-006.jpg", "result": "419055603900009001012999"}, | ||
{"name": "image-007.jpg", "result": "T 000003552345"}, | ||
{"name": "image-008.jpg", "result": "FANAVF1461710"}, | ||
{"name": "image-009.jpg", "result": "0001285112001000040801"}, | ||
{"name": "image-010.jpg", "result": "673023"} | ||
]; | ||
{"name": "image-001.jpg", "result": "0001285112001000040801"}, | ||
// {"name": "image-002.jpg", "result": "FANAVF1461710"}, | ||
// {"name": "image-003.jpg", "result": "673023"}, | ||
{"name": "image-004.jpg", "result": "010210150301625334"}, | ||
{"name": "image-005.jpg", "result": "419055603900009001012999"}, | ||
{"name": "image-006.jpg", "result": "419055603900009001012999"}, | ||
{"name": "image-007.jpg", "result": "T 000003552345"}, | ||
{"name": "image-008.jpg", "result": "FANAVF1461710"}, | ||
{"name": "image-009.jpg", "result": "0001285112001000040801"}, | ||
{"name": "image-010.jpg", "result": "673023"} | ||
]; | ||
testSet.forEach(function(sample) { | ||
sample.format = "code_128"; | ||
}); | ||
config.decoder.readers = ['code_128_reader']; | ||
@@ -90,14 +99,18 @@ _runTestSet(testSet, config); | ||
testSet = [ | ||
{"name": "image-001.jpg", "result": "B3% $DAD$"}, | ||
/*{"name": "image-002.jpg", "result": "QUAGGAJS"},*/ | ||
{"name": "image-003.jpg", "result": "CODE39"}, | ||
{"name": "image-004.jpg", "result": "QUAGGAJS"}, | ||
/* {"name": "image-005.jpg", "result": "CODE39"}, */ | ||
{"name": "image-006.jpg", "result": "2/4-8/16-32"}, | ||
{"name": "image-007.jpg", "result": "2/4-8/16-32"}, | ||
{"name": "image-008.jpg", "result": "CODE39"}, | ||
{"name": "image-009.jpg", "result": "2/4-8/16-32"}, | ||
{"name": "image-010.jpg", "result": "CODE39"} | ||
]; | ||
{"name": "image-001.jpg", "result": "B3% $DAD$"}, | ||
/*{"name": "image-002.jpg", "result": "QUAGGAJS"},*/ | ||
{"name": "image-003.jpg", "result": "CODE39"}, | ||
{"name": "image-004.jpg", "result": "QUAGGAJS"}, | ||
/* {"name": "image-005.jpg", "result": "CODE39"}, */ | ||
{"name": "image-006.jpg", "result": "2/4-8/16-32"}, | ||
{"name": "image-007.jpg", "result": "2/4-8/16-32"}, | ||
{"name": "image-008.jpg", "result": "CODE39"}, | ||
{"name": "image-009.jpg", "result": "2/4-8/16-32"}, | ||
{"name": "image-010.jpg", "result": "CODE39"} | ||
]; | ||
testSet.forEach(function(sample) { | ||
sample.format = "code_39"; | ||
}); | ||
config.decoder.readers = ['code_39_reader']; | ||
@@ -110,14 +123,18 @@ _runTestSet(testSet, config); | ||
testSet = [ | ||
{"name": "image-001.jpg", "result": "42191605"}, | ||
{"name": "image-002.jpg", "result": "42191605"}, | ||
{"name": "image-003.jpg", "result": "90311208"}, | ||
{"name": "image-004.jpg", "result": "24057257"}, | ||
{"name": "image-005.jpg", "result": "90162602"}, | ||
{"name": "image-006.jpg", "result": "24036153"}, | ||
{"name": "image-007.jpg", "result": "42176817"}, | ||
/*{"name": "image-008.jpg", "result": "42191605"},*/ | ||
{"name": "image-009.jpg", "result": "42242215"}, | ||
{"name": "image-010.jpg", "result": "42184799"} | ||
]; | ||
{"name": "image-001.jpg", "result": "42191605"}, | ||
{"name": "image-002.jpg", "result": "42191605"}, | ||
{"name": "image-003.jpg", "result": "90311208"}, | ||
{"name": "image-004.jpg", "result": "24057257"}, | ||
{"name": "image-005.jpg", "result": "90162602"}, | ||
{"name": "image-006.jpg", "result": "24036153"}, | ||
{"name": "image-007.jpg", "result": "42176817"}, | ||
/*{"name": "image-008.jpg", "result": "42191605"},*/ | ||
{"name": "image-009.jpg", "result": "42242215"}, | ||
{"name": "image-010.jpg", "result": "42184799"} | ||
]; | ||
testSet.forEach(function(sample) { | ||
sample.format = "ean_8"; | ||
}); | ||
config.decoder.readers = ['ean_8_reader']; | ||
@@ -142,2 +159,6 @@ _runTestSet(testSet, config); | ||
testSet.forEach(function(sample) { | ||
sample.format = "upc_a"; | ||
}); | ||
config.decoder.readers = ['upc_reader']; | ||
@@ -162,2 +183,6 @@ _runTestSet(testSet, config); | ||
testSet.forEach(function(sample) { | ||
sample.format = "upc_e"; | ||
}); | ||
config.decoder.readers = ['upc_e_reader']; | ||
@@ -182,2 +207,6 @@ _runTestSet(testSet, config); | ||
testSet.forEach(function(sample) { | ||
sample.format = "codabar"; | ||
}); | ||
config.decoder.readers = ['codabar_reader']; | ||
@@ -184,0 +213,0 @@ _runTestSet(testSet, config); |
@@ -52,4 +52,3 @@ /* jshint undef: true, unused: true, browser:true, devel: true */ | ||
}, | ||
_barcodeReaders = [], | ||
_barcodeReader = null; | ||
_barcodeReaders = []; | ||
@@ -175,5 +174,2 @@ initCanvas(); | ||
result = _barcodeReaders[i].decodePattern(barcodeLine.line); | ||
if (result !== null) { | ||
_barcodeReader = _barcodeReaders[i]; | ||
} | ||
} | ||
@@ -180,0 +176,0 @@ if(result === null){ |
@@ -169,2 +169,5 @@ /* jshint undef: true, unused: true, browser:true, devel: true */ | ||
} | ||
if (result) { | ||
result.format = self.FORMAT; | ||
} | ||
return result; | ||
@@ -184,2 +187,7 @@ }; | ||
}; | ||
Object.defineProperty(BarcodeReader.prototype, "FORMAT", { | ||
value: 'unknown', | ||
writeable: false | ||
}); | ||
@@ -186,0 +194,0 @@ BarcodeReader.DIRECTION = { |
@@ -23,3 +23,4 @@ /* jshint undef: true, unused: true, browser:true, devel: true */ | ||
MAX_ACCEPTABLE: {value: 2.0}, | ||
PADDING: {value: 1.5} | ||
PADDING: {value: 1.5}, | ||
FORMAT: {value: "codabar", writeable: false} | ||
}; | ||
@@ -26,0 +27,0 @@ |
@@ -135,3 +135,4 @@ /* jshint undef: true, unused: true, browser:true, devel: true */ | ||
SINGLE_CODE_ERROR: {value: 1}, | ||
AVG_CODE_ERROR: {value: 0.5} | ||
AVG_CODE_ERROR: {value: 0.5}, | ||
FORMAT: {value: "code_128", writeable: false} | ||
}; | ||
@@ -183,55 +184,3 @@ | ||
}; | ||
Code128Reader.prototype._findEnd = function() { | ||
var counter = [0, 0, 0, 0, 0, 0, 0], | ||
i, | ||
self = this, | ||
offset = self._nextSet(self._row), | ||
isWhite = !self._row[offset], | ||
counterPos = 0, | ||
bestMatch = { | ||
error : Number.MAX_VALUE, | ||
code : -1, | ||
start : 0, | ||
end : 0 | ||
}, | ||
error, | ||
j, | ||
sum, | ||
normalized; | ||
for ( i = offset; i < self._row.length; i++) { | ||
if (self._row[i] ^ isWhite) { | ||
counter[counterPos]++; | ||
} else { | ||
if (counterPos === counter.length - 1) { | ||
sum = 0; | ||
for ( j = 0; j < counter.length; j++) { | ||
sum += counter[j]; | ||
} | ||
normalized = self._normalize(counter, 13); | ||
error = self._matchPattern(normalized, self.CODE_PATTERN[self.STOP_CODE]); | ||
if (error < self.AVG_CODE_ERROR) { | ||
bestMatch.error = error; | ||
bestMatch.start = i - sum; | ||
bestMatch.end = i; | ||
return bestMatch; | ||
} | ||
for ( j = 0; j < 5; j++) { | ||
counter[j] = counter[j + 2]; | ||
} | ||
counter[5] = 0; | ||
counter[6] = 0; | ||
counterPos--; | ||
} else { | ||
counterPos++; | ||
} | ||
counter[counterPos] = 1; | ||
isWhite = !isWhite; | ||
} | ||
} | ||
return null; | ||
}; | ||
Code128Reader.prototype._findStart = function() { | ||
@@ -425,3 +374,3 @@ var counter = [0, 0, 0, 0, 0, 0], | ||
code.end = self._nextUnset(self._row, code.end); | ||
if (code.end === self._row.length) { | ||
if(!self._verifyTrailingWhitespace(code)){ | ||
return null; | ||
@@ -437,5 +386,11 @@ } | ||
if (!result.length) { | ||
return null; | ||
} | ||
// remove last code from result (checksum) | ||
result.splice(result.length - 1, 1); | ||
return { | ||
@@ -451,2 +406,16 @@ code : result.join(""), | ||
}; | ||
BarcodeReader.prototype._verifyTrailingWhitespace = function(endInfo) { | ||
var self = this, | ||
trailingWhitespaceEnd; | ||
trailingWhitespaceEnd = endInfo.end + ((endInfo.end - endInfo.start) / 2); | ||
if (trailingWhitespaceEnd < self._row.length) { | ||
if (self._matchRange(endInfo.end, trailingWhitespaceEnd, 0)) { | ||
return endInfo; | ||
} | ||
} | ||
return null; | ||
}; | ||
@@ -453,0 +422,0 @@ return (Code128Reader); |
@@ -20,3 +20,4 @@ /* jshint undef: true, unused: true, browser:true, devel: true */ | ||
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} | ||
}; | ||
@@ -23,0 +24,0 @@ |
@@ -15,3 +15,7 @@ /* jshint undef: true, unused: true, browser:true, devel: true */ | ||
EAN8Reader.prototype = Object.create(EANReader.prototype); | ||
var properties = { | ||
FORMAT: {value: "ean_8", writeable: false} | ||
}; | ||
EAN8Reader.prototype = Object.create(EANReader.prototype, properties); | ||
EAN8Reader.prototype.constructor = EAN8Reader; | ||
@@ -18,0 +22,0 @@ |
@@ -46,3 +46,4 @@ /* jshint undef: true, unused: true, browser:true, devel: true */ | ||
SINGLE_CODE_ERROR: {value: 0.7}, | ||
AVG_CODE_ERROR: {value: 0.3} | ||
AVG_CODE_ERROR: {value: 0.3}, | ||
FORMAT: {value: "ean_13", writeable: false} | ||
}; | ||
@@ -49,0 +50,0 @@ |
@@ -19,3 +19,4 @@ /* jshint undef: true, unused: true, browser:true, devel: true */ | ||
[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} | ||
}; | ||
@@ -22,0 +23,0 @@ |
@@ -15,3 +15,7 @@ /* jshint undef: true, unused: true, browser:true, devel: true */ | ||
UPCReader.prototype = Object.create(EANReader.prototype); | ||
var properties = { | ||
FORMAT: {value: "upc_a", writeable: false} | ||
}; | ||
UPCReader.prototype = Object.create(EANReader.prototype, properties); | ||
UPCReader.prototype.constructor = UPCReader; | ||
@@ -18,0 +22,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1926358
43480
396