piderman314 / bardecoder

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

Panics on rotated image #11

Closed jjhbw closed 4 years ago

jjhbw commented 4 years ago

Hi! Thanks for the nice lib. I've been studying it a bit in hopes of understanding more of how QR codes are detected and decoded on a low level.

To see how well the line scan method fares against arbitrary image rotations, I tried the detector on the below image.

It ends up panicking right here (al_y > image bounds): https://github.com/piderman314/bardecoder/blob/02d2c69a4557034d782b645e3ac6feabdb024849/src/extract/qr/mod.rs#L178

The image in question (found it online somewhere and rotated it a bit):

wild_rot

If you don't have the time on hand to fix this yourself, just point me in the right direction.

piderman314 commented 4 years ago

Ok I've made a little bit of progress. I have to say though, very large images like these are always difficult because it has a lot of noise. However, the library now correctly detects two of the locator patterns. If you resize it to 25% it tries to extract data but not entirely correctly. If you resize to 25% and rotate by 180 degrees it now correctly decodes (it didn't previously). I'll see if I can improve things a bit more ;)

jjhbw commented 4 years ago

Pretty great! it seems the panic issue is at least solved. I'll open a new issue and a WIP PR with a the above image as a failing test case.

I know next to nothing about QR code detection, but i'm planning on playing around with it a bit.