ZXing.Net icon indicating copy to clipboard operation
ZXing.Net copied to clipboard

Can't decode UPC-E and EAN-8 barcodes if they are on the same page.

Open sabiinlaw opened this issue 3 years ago • 9 comments

I tried to use different barcode readers (BarcodeReader, GenericMultipleBarcodeReader) to decode single page file with multiple barcodes, but it can't find both UPC-E and EAN-8 barcodes together.

  1. It finds only UPC-E barcode if EAN-8 is on the same row.
  2. If I change input image file and move UPC-E barcode to another row - than EAN-8 is found, but UPC-E isn't. Please see attached test files: image1 image2

sabiinlaw avatar May 24 '22 13:05 sabiinlaw

ZXing.Net uses a very simple algorithm to find more than one barcode inside an image. Because of that, it can happen that not all codes will be found. Feel free to provide a PR with some enhancements.

micjahn avatar Jun 01 '22 18:06 micjahn

Maybe as a workaround you can draw something (e.g. a rectangle) over the detected barcores, using the ResultPoints in the result, and trigger another decode?

Lakritzator avatar Jun 29 '22 14:06 Lakritzator

Works only for 2D codes. For 1D codes you are getting only a line as the result points, not the whole rectangle.

micjahn avatar Jun 30 '22 16:06 micjahn

As a workaround I tried some solutions from this article (https://localcoder.org/zxing-finding-the-bounding-rectangle-of-barcode), but it's not always possible to find correct coordinates. For now it is not that critical for me if some barcodes are missed and looks like a rare case when 2 barcodes placed exactly on same line. Thank you for your support 👍

sabiinlaw avatar Jun 30 '22 21:06 sabiinlaw

Not directly on topic, but some background information:

@micjahn I actually had a bit of an similar challenge, I added ZWing to Greenshot so it was able to provide the user with a way to use bar/QR codes on the screen. I noticed that it failed to find all when there are multiple. Back then I did the workaround which I mentioned, but I never released the functionality so there wasn't a lot of testing, I probably missed the use-case with a 1D code 🤷‍♂️ .

I might come back to that use-case, I also have similar stuff with text in the most recent versions, where one can select text (for the clipboard) directly from the screenshot. I was hoping to be able have the QR code positions too.

Example: image

Lakritzator avatar Jun 30 '22 22:06 Lakritzator

grafik The green rectangle shows the result points for QR decoding. In that case, it would work.

PDF417 should also work grafik

And this is a sample for 1D decoding grafik

ZXing saves the additional CPU cycles which are needed to find the whole rectangle.

micjahn avatar Jul 01 '22 06:07 micjahn

Thanks a lot for the thorough feedback, your examples is what I saw when I got the ResultPoints. But I never tested a 1D variant, that makes total sense for the recognition. 👍

Lakritzator avatar Jul 01 '22 06:07 Lakritzator

For whom it may concern: https://github.com/zxing-cpp/zxing-cpp/ uses a completely different approach to detect multiple symbols in one image and detects all of the 9 symbols in the first image above just fine.

axxel avatar Jul 23 '23 23:07 axxel

As a followup to my comment from last year: zxing-cpp now comes with a .NET wrapper.

axxel avatar Feb 04 '24 21:02 axxel