ericblade / quagga2

An advanced barcode-scanner written in Javascript and TypeScript - Continuation from https://github.com/serratus/quaggajs
MIT License
761 stars 85 forks source link

Unable to scan barcodes on iPhone SE 2016 #408

Closed olefjaerestad closed 2 years ago

olefjaerestad commented 2 years ago

Hi,

I searched through the issues, but couldn't find this exact one. Do let me know if there's already an identical issue, and if so, this one can be closed.

Using Quagga.decodeSingle, no barcode is detected on my iPhone SE 2016 edition, neither in Safari 15.2 nor Chrome 99. This is the code:

await Quagga.decodeSingle({
  src: imageSrc,
  decoder: {
    multiple: true,
  },
  readers: ["ean_reader"],
  locator: {
    halfSample: true,
    patchSize: 'small',
  },
  inputStream: {
    size: 1280,
  }
});

Where imageSrc is a PNG data URI. You can get the URI from this codepen and the PNG itself from here. The image was taken with the rear camera on said iPhone SE. It's an ean_13 code. The returned result is null. I get the same result using Quagga.init directly. Using the exact same code and image works well in Chrome 99 on macOS.

What's even more interesting is that using the following code with the original library seems to work fine (in the sense that it at least returns an array of 1 box):

Quagga.decodeSingle({
  src: imageSrc,
  decoder: {
    multiple: true,
  },
  readers: ["ean_reader"],
  locator: {
    halfSample: true,
    patchSize: 'small',
  },
  inputStream: {
    size: 1280,
  }
}, (barcode) => alert(JSON.stringify(barcode)));

Indicating that some change in Quagga2 has affected the behaviour. I'm able to use the original library for now, but in the long run I'd prefer to upgrade to v2, as I really enjoy the typescript typings and the fact that it seems to be well maintained.

Image recognition is by no means something I'm good at, but I've done some high-level debugging and found a couple of potentially relevant things:

Let me know if I can provide any more info to support debugging. Keep up the good work!

github-actions[bot] commented 2 years ago

Thank you for filing an issue! Please be patient. :-)

ericblade commented 2 years ago

OK, this is some great information. This is going to take me a little bit of time to unpack.

My first question -- do you have a data URI that decodes properly? If so, could you also supply that, so that I can add a working data URI test to the test suite, and perhaps the non-working one as well, which might also shed some light on where a difference lies?

I'm going to take a deeper dive into the information you've provided, and will probably have more questions.

Thank you!

ericblade commented 2 years ago

er.. are you saying this affects every barcode on this particular model device, or is it specific ones like this example that are failing?

olefjaerestad commented 2 years ago

Sorry for the late reply here. I've been unsuccessful in recreating the issue. Not sure why it would start working all of a sudden. You can consider this issue solved. I'll create a new issue (with more specific steps to reproduce) if the issue reoccurs. Once again, thanks for the work you're doing!