serratus / quaggaJS

An advanced barcode-scanner written in JavaScript
https://serratus.github.io/quaggaJS/
MIT License
5.08k stars 978 forks source link

Quagga does not find any ean barcodes? #389

Open fhogstrom opened 5 years ago

fhogstrom commented 5 years ago

I have been trying to figure out the correct configurations for quite some time now, with minimal luck. We need the scanner to be able to read EAN barcodes but they all come back as not deteced. Works fine for some types of barcodes but not ean.

      `function myfunc(e) {
             var reader = new FileReader();
             reader.onload = function(event) {
             Quagga.decodeSingle(
              {
          decoder: {
            readers: [
              "upc_reader",
              "code_128_reader",
              "code_39_reader",
              "code_39_vin_reader",
              "ean_8_reader",
              "ean_reader",
              "upc_e_reader",
              "codabar_reader"
            ]
          },
          locator: {
            patchSize: "large",
            halfSample: true
          },
          numOfWorkers: 0,
          locate: true,
          multiple: true,

          src: event.target.result
        },
        function(result) {
          if (result.codeResult) {
            console.log(result.codeResult.code);
          } else {
            console.log("not detected");
          }
        }
      );
    };
    reader.readAsDataURL(e.target.files[0]);
  }`

What could be wrong? Sorry for the formatting

ericblade commented 5 years ago

First thing I would do is remove all the irrelevant readers. The more readers you have running, the more problems you will have with different readers potentially making matches, and it's not very efficient even when it does work well. I'd also try disabling "multiple" and more closely checking what you might be getting in "result", i think the output is slightly different between multiple and single modes. Lastly, I'd try playing with the locator settings.

fhogstrom commented 5 years ago

First thing I would do is remove all the irrelevant readers. The more readers you have running, the more problems you will have with different readers potentially making matches, and it's not very efficient even when it does work well. I'd also try disabling "multiple" and more closely checking what you might be getting in "result", i think the output is slightly different between multiple and single modes. Lastly, I'd try playing with the locator settings.

Ok thanks, would readers: ["ean_reader"] cover all the ean codes? I noticed there is no "ean_13_reader"?

ericblade commented 5 years ago

I think so? I use this configuration for reading standard product UPC/EAN/ISBN barcodes:

            decoder: {
                readers: ['upc_reader', 'ean_reader'],
            },
fhogstrom commented 5 years ago

I think so? I use this configuration for reading standard product UPC/EAN/ISBN barcodes:

            decoder: {
                readers: ['upc_reader', 'ean_reader'],
            },

Thanks for the prompt reply, still same issue though. Could you post me a working example with code?

ericblade commented 5 years ago

i don't have anything that uses decodeSingle, but I could point to tests..

https://github.com/ericblade/quagga2/blob/master/test/integration/integration.spec.js

the tests use a config that looks like

       return {
            inputStream: {
                size: 640
            },
            locator: {
                patchSize: "medium",
                halfSample: true
            },
            numOfWorkers: 0,
            decoder: {
                readers: ["ean_reader"]
            },
            locate: true,
            src: null
        };

they set the reader for each type, the src for each file, and then run decodeSingle on each of the files in the test set

ericblade commented 5 years ago

i see you're missing an inputStream, i'm not sure if that's a problem or not, I use the livestream rather than decoding files.

kgrosvenor commented 3 years ago

I dont think ean_13_reader is a thing ? Any idea why it wont work?

Quagga.decodeSingle({
  decoder: {
    readers: [{
      format: "ean_reader",
      config: {
        supplements: [
          'ean_13_reader',
          'ean_8_reader',
        ]
      }
    }]
  },
  locate: true, // try to locate the barcode in the image
  src: src
}, function (result) {
  if (result.codeResult) {
    console.log("result", result);
    console.log("result", result.codeResult.code);
  } else {
    console.log(result);
    console.log("not detected");
  }
});
ericblade commented 3 years ago

Try a basic config like decoder: { readers: ["ean_reader"] },

get that working first. I can't find any reference to a ean_13_reader or a ean_8_reader, are those something you see somewhere?

what are you trying to read specifically?