rxing-core / rxing

cRustacean Crossing
https://crates.io/crates/rxing
Apache License 2.0
198 stars 19 forks source link

Multiple barcode decoder issue #51

Closed TonyMasson closed 2 months ago

TonyMasson commented 2 months ago

Hello,

First of all, thank you for all the work you have done.

I am encountering an issue with the detection of multiple DataMatrix codes in an image.

In the image below, we get an error of type Err(NotFoundException("")) because the first DataMatrix code in the image is, I believe, detected but is blurry on its right side (you can see it clearly by zooming in). However, the second DataMatrix code is good but not detected.

BAD

If I swap the two DataMatrix codes, the first one is detected and everything works as expected. GOOD

Thank you very much.

hschimke commented 2 months ago

I'll look into this. I'm out of office until next week, but I'll try to provide an update by midweek.

hschimke commented 2 months ago

Stepping through the detection logic it appears that you are correct. There is just enough distortion that one of the symbols fails error correction.

The issue is that the datamatrix detector, unlike the qr detector, only returns a single possible symbol. For "multiple detection" this is usually fine because the image is then chopped up and rescanned, but in this particular case that does not occur and so only one symbol in the entire image is ever parsed. I have updated the logic of the detector to return all possible symbol locations and to iterate over them. This has a slight reduction in performance in some cases, but overall should result in better detection results.

I have a working fix in testing.

TonyMasson commented 2 months ago

🙏 Thanks

hschimke commented 2 months ago

This release has been published to crates.io and to rxing-wasm v0.2.9