piderman314 / bardecoder

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

Enable detection of codes with homographic transformations #48

Closed stephanemagnenat closed 1 year ago

stephanemagnenat commented 1 year ago

Currently, the QRLocation only stores the positions of the 3 finder patterns, but not the position of the alignment marking. If it would do so, it would allow the subsequent passes to handle codes seen not frontally, because we could compute a 2-D homography between the visual space and the code space.

@piderman314 would you potentially be open to adding such a field (as an option, as version 1 lacks it)?

At the moment, bardecoder is not able to decode QR codes with perspective transforms, such as these ones: qrcode-perspective1 qrcode-perspective2

This is a problem for AR/vision applications.

piderman314 commented 1 year ago

Hey, I've had a look at this. bardecoder already used the alignment pattern to detect perspective. It worked for the first image you posted but the second was too skewed and the library thought it was a version 1 QR while it isn't. I've improved the code a bit and now it correctly 'guesses' that it is a version 2 QR and can also use the alignment pattern to decode the second image. Do you need the location of the alignment pattern to be exposed for your own application or is the issue resolved now that the QRs can be decoded?

stephanemagnenat commented 1 year ago

Thank you for the improvement! I think that now it is ok, after some experiments I would go for two QR codes for robustness when looking for homographic transformations.

piderman314 commented 1 year ago

Excellent. I've published version 0.4.2 for ease of use.