afriscic / BarcodeScanning.Native.Maui

Barcode scanning library for .NET MAUI
https://www.nuget.org/packages/BarcodeScanning.Native.Maui
MIT License
183 stars 33 forks source link

Multiple different reads from the same Barcode #54

Closed OuTseries closed 6 months ago

OuTseries commented 6 months ago

Good morning,

I'm having problems with reading barcodes. A single barcode is giving me 10+ different results. An example would be a code-39 ZB00008477 reads: ZB00008477 ZB0008477 Z80008477 Z800008477 B00008477 ZB0008SP W80008477 ...

I'm using the last version of the package with AimMode enabled.

Any ideas on why this is happening and how to fix it?

Olaf-R commented 6 months ago

I also have issues with Code39 barcodes. I had filed issue #42 for this.

I dived quite a bit into Google's BarcodeScanner lib a while ago. The root of the problem might be that the lib doesn't seem to respect the start and stop delimiters (see the Wikipedia article on Code 39), hence the scanner will scan incomplete barcodes which thus leads to wrong results. To test, all you need to do is to cover a small portion at the beginning or the end of a Code 39 barcode. The scanner should not react in thoses cases as the scanned value is incomplete. It does return a result though which might be just what you are seeing.

As long as there is no solution to this problem, my app is additionally checking the length and contents of a scanned code; upon finding any invalid/incomplete codes it will show a little toast-message. That's the best I could come up with.

FWIW, I have always seen identical values in DisplayValue and RawValue when I would have expected the asterisks to show up.

However, all of the above may be totally wrong, too.

Interesting to see that you seem to be doing the same thing - a two character type-prefix along with a numeric ID, the only dif being that my ID maxes out at 6 digits instead of 8. :-)

afriscic commented 6 months ago

Thank you for great info @Olaf-R. Yes, this seems as MLKit problem. You can file a bug report here but from my experience Google is now focusing on other stuff and all proposals about barcode scanning gets rejected.

Arasal commented 6 months ago

I'm having the same issue with RawValue not displaying the asterisks. I have no way of verifying my barcodes on wrong reads.

Almost all our barcodes are in Code 39 with asterisks characters at the start and end of the barcodes.

Does the library tries to detect the barcode from a single image or multiple images ? In issue #42 you talked about the parameter PoolingInterval. How does it affect scanning ?

afriscic commented 6 months ago

It looks like an issue with how Google MLKit handles Code39 barcodes, so unfortunately there is little that I can do. Pooling just combines recognised barcodes from multiple frames. i don't think it will help with your issue. Apple has internally 4 different subsets of Code39 symbology so on iOS i could implement fine selection of what Code39 barcodes get recognised.

OuTseries commented 6 months ago

Thank you so much for the replies. I think i might be able to use code 128 and avoid this issue. Still thanks for the attempt at improving it