piderman314 / bardecoder

Detect and decode QR Codes, written in 100% Rust.
MIT License
268 stars 34 forks source link

Can't decode barcode unless scaled up #25

Open KyleMaas opened 4 years ago

KyleMaas commented 4 years ago

I can't decode this test barcode: stresstest-only-120dpi

But I can if I size it up by 2x with no interpolation: stresstest-only-120dpi-expanded

piderman314 commented 4 years ago

This is an unfortunate side effect of having to detect QR codes in fuzzy images. There's a lot of interpolation and rounding going on. In the case where the QR is an exact size pixel-for-pixel, the calculated locations are sliiightly off (0.5px in x direction, 1px in y direction :P) and and such the alignment pattern can't be found, and the data extraction fails as well. Some extra code would be needed to see that it's a 1px-QR and adjust accordingly.

When the modules are 2px wide already the rounding doesn't matter anymore.