diff --git a/example/file_input.html b/example/file_input.html index ec67890..4c67414 100644 --- a/example/file_input.html +++ b/example/file_input.html @@ -46,6 +46,7 @@ + diff --git a/example/file_input.js b/example/file_input.js index cccf288..9b9420e 100644 --- a/example/file_input.js +++ b/example/file_input.js @@ -82,21 +82,37 @@ $(function() { }, decoder: { readers: function(value) { - return [value + "_reader"]; + if (value === 'ean_extended') { + return [{ + format: "ean_reader", + config: { + supplements: [ + 'ean_5_reader', 'ean_2_reader' + ] + } + }]; + } + return [{ + format: value + "_reader", + config: {} + }]; } } }, state: { inputStream: { - size: 640, + size: 800, singleChannel: false }, locator: { - patchSize: "large", - halfSample: false + patchSize: "medium", + halfSample: true }, decoder: { - readers: ["code_128_reader"] + readers: [{ + format: "code_128_reader", + config: {} + }] }, locate: true, src: null diff --git a/example/live_w_locator.html b/example/live_w_locator.html index 31f55ac..a8a3787 100644 --- a/example/live_w_locator.html +++ b/example/live_w_locator.html @@ -38,6 +38,7 @@ + diff --git a/example/live_w_locator.js b/example/live_w_locator.js index 350a0f6..c058bd2 100644 --- a/example/live_w_locator.js +++ b/example/live_w_locator.js @@ -107,7 +107,20 @@ $(function() { }, decoder: { readers: function(value) { - return [value + "_reader"]; + if (value === 'ean_extended') { + return [{ + format: "ean_reader", + config: { + supplements: [ + 'ean_5_reader', 'ean_2_reader' + ] + } + }]; + } + return [{ + format: value + "_reader", + config: {} + }]; } } }, @@ -126,7 +139,10 @@ $(function() { }, numOfWorkers: 4, decoder: { - readers : [ "code_128_reader"] + readers : [{ + format: "code_128_reader", + config: {} + }] }, locate: true }, diff --git a/example/static_images.html b/example/static_images.html index 49acca6..307c168 100644 --- a/example/static_images.html +++ b/example/static_images.html @@ -39,6 +39,7 @@ + diff --git a/example/static_images.js b/example/static_images.js index 588d793..fecdf92 100644 --- a/example/static_images.js +++ b/example/static_images.js @@ -1,7 +1,7 @@ $(function() { var App = { init: function() { - var config = this.config[this.state.decoder.readers[0]] || this.config.default; + var config = this.config[this.state.decoder.readers[0].format] || this.config.default; config = $.extend(true, {}, config, this.state); Quagga.init(config, function() { App.attachListeners(); @@ -95,7 +95,20 @@ $(function() { inputMapper: { decoder: { readers: function(value) { - return [value + "_reader"]; + if (value === 'ean_extended') { + return [{ + format: "ean_reader", + config: { + supplements: [ + 'ean_5_reader', 'ean_2_reader' + ] + } + }]; + } + return [{ + format: value + "_reader", + config: {} + }]; } }, inputStream: { @@ -109,7 +122,10 @@ $(function() { src: "../test/fixtures/code_128/" }, decoder : { - readers : ["code_128_reader"] + readers : [{ + format: "code_128_reader", + config: {} + }] } } }; diff --git a/test/fixtures/ean_extended/download (1).png b/test/fixtures/ean_extended/download (1).png new file mode 100644 index 0000000..f03deb4 Binary files /dev/null and b/test/fixtures/ean_extended/download (1).png differ diff --git a/test/fixtures/ean_extended/download (10).png b/test/fixtures/ean_extended/download (10).png new file mode 100644 index 0000000..25e10b3 Binary files /dev/null and b/test/fixtures/ean_extended/download (10).png differ diff --git a/test/fixtures/ean_extended/download (12).png b/test/fixtures/ean_extended/download (12).png new file mode 100644 index 0000000..4aec63c Binary files /dev/null and b/test/fixtures/ean_extended/download (12).png differ diff --git a/test/fixtures/ean_extended/download (2).png b/test/fixtures/ean_extended/download (2).png new file mode 100644 index 0000000..f574922 Binary files /dev/null and b/test/fixtures/ean_extended/download (2).png differ diff --git a/test/fixtures/ean_extended/download (3).png b/test/fixtures/ean_extended/download (3).png new file mode 100644 index 0000000..c9b4bef Binary files /dev/null and b/test/fixtures/ean_extended/download (3).png differ diff --git a/test/fixtures/ean_extended/download (4).png b/test/fixtures/ean_extended/download (4).png new file mode 100644 index 0000000..7c4ea17 Binary files /dev/null and b/test/fixtures/ean_extended/download (4).png differ diff --git a/test/fixtures/ean_extended/download (5).png b/test/fixtures/ean_extended/download (5).png new file mode 100644 index 0000000..c2c6095 Binary files /dev/null and b/test/fixtures/ean_extended/download (5).png differ diff --git a/test/fixtures/ean_extended/download (6).png b/test/fixtures/ean_extended/download (6).png new file mode 100644 index 0000000..fd6402a Binary files /dev/null and b/test/fixtures/ean_extended/download (6).png differ diff --git a/test/fixtures/ean_extended/download (7).png b/test/fixtures/ean_extended/download (7).png new file mode 100644 index 0000000..926d3d2 Binary files /dev/null and b/test/fixtures/ean_extended/download (7).png differ diff --git a/test/fixtures/ean_extended/download (8).png b/test/fixtures/ean_extended/download (8).png new file mode 100644 index 0000000..9369814 Binary files /dev/null and b/test/fixtures/ean_extended/download (8).png differ diff --git a/test/fixtures/ean_extended/download (9).png b/test/fixtures/ean_extended/download (9).png new file mode 100644 index 0000000..1781174 Binary files /dev/null and b/test/fixtures/ean_extended/download (9).png differ diff --git a/test/fixtures/ean_extended/image-001.jpg b/test/fixtures/ean_extended/image-001.jpg new file mode 100644 index 0000000..0bf2ce2 Binary files /dev/null and b/test/fixtures/ean_extended/image-001.jpg differ diff --git a/test/fixtures/ean_extended/image-002.jpg b/test/fixtures/ean_extended/image-002.jpg new file mode 100644 index 0000000..5d6d9eb Binary files /dev/null and b/test/fixtures/ean_extended/image-002.jpg differ diff --git a/test/fixtures/ean_extended/image-003.jpg b/test/fixtures/ean_extended/image-003.jpg new file mode 100644 index 0000000..c04f4e8 Binary files /dev/null and b/test/fixtures/ean_extended/image-003.jpg differ diff --git a/test/fixtures/ean_extended/image-004.jpg b/test/fixtures/ean_extended/image-004.jpg new file mode 100644 index 0000000..1ed3cbc Binary files /dev/null and b/test/fixtures/ean_extended/image-004.jpg differ diff --git a/test/fixtures/ean_extended/image-005.jpg b/test/fixtures/ean_extended/image-005.jpg new file mode 100644 index 0000000..5cf81a7 Binary files /dev/null and b/test/fixtures/ean_extended/image-005.jpg differ diff --git a/test/fixtures/ean_extended/image-006.jpg b/test/fixtures/ean_extended/image-006.jpg new file mode 100644 index 0000000..92f7cfd Binary files /dev/null and b/test/fixtures/ean_extended/image-006.jpg differ diff --git a/test/fixtures/ean_extended/image-007.jpg b/test/fixtures/ean_extended/image-007.jpg new file mode 100644 index 0000000..599e442 Binary files /dev/null and b/test/fixtures/ean_extended/image-007.jpg differ diff --git a/test/fixtures/ean_extended/image-008.jpg b/test/fixtures/ean_extended/image-008.jpg new file mode 100644 index 0000000..c93b591 Binary files /dev/null and b/test/fixtures/ean_extended/image-008.jpg differ diff --git a/test/fixtures/ean_extended/image-009.jpg b/test/fixtures/ean_extended/image-009.jpg new file mode 100644 index 0000000..17fe6c2 Binary files /dev/null and b/test/fixtures/ean_extended/image-009.jpg differ diff --git a/test/fixtures/ean_extended/image-010.jpg b/test/fixtures/ean_extended/image-010.jpg new file mode 100644 index 0000000..3869850 Binary files /dev/null and b/test/fixtures/ean_extended/image-010.jpg differ diff --git a/test/integration/integration.spec.js b/test/integration/integration.spec.js index 10f9286..4ff125d 100644 --- a/test/integration/integration.spec.js +++ b/test/integration/integration.spec.js @@ -27,15 +27,19 @@ describe('decodeSingle', function () { function _runTestSet(testSet, config) { var readers = config.decoder.readers.slice(), format, - folder; + folder, + suffix; if (typeof readers[0] === 'string'){ format = readers[0]; } else { + if (readers[0].config && readers[0].config.supplements && readers[0].config.supplements.length) { + suffix = "extended"; + } format = readers[0].format; } - folder = baseFolder + format.split('_').slice(0, -1).join('_') + "/"; + folder = baseFolder + format.split('_').slice(0, -1).concat(suffix ? [suffix] : []).join('_') + "/"; it('should decode ' + folder + " correctly", function(done) { async.eachSeries(testSet, function (sample, callback) { @@ -76,6 +80,49 @@ describe('decodeSingle', function () { _runTestSet(testSet, config); }); + describe("EAN-extended", function() { + var config = { + inputStream: { + size: 800, + singleChannel: false + }, + locator: { + patchSize: "medium", + halfSample: true + }, + numOfWorkers: 0, + decoder: { + readers: [{ + format: "ean_reader", + config: { + supplements: [ + 'ean_5_reader', 'ean_2_reader' + ] + } + }] + }, + locate: true, + src: null + }, + testSet = [ + {"name": "image-001.jpg", "result": "900437801102701"}, + {"name": "image-002.jpg", "result": "419871600890101"}, + {"name": "image-003.jpg", "result": "419871600890101"}, + {"name": "image-004.jpg", "result": "978054466825652495"}, + {"name": "image-005.jpg", "result": "419664190890712"}, + {"name": "image-006.jpg", "result": "412056690699101"}, + {"name": "image-007.jpg", "result": "419204531290601"}, + {"name": "image-008.jpg", "result": "419871600890101"}, + {"name": "image-009.jpg", "result": "978054466825652495"}, + {"name": "image-010.jpg", "result": "900437801102701"} + ]; + + testSet.forEach(function(sample) { + sample.format = "ean_13"; + }); + _runTestSet(testSet, config); + }); + describe("Code128", function() { var config = { inputStream: {