piderman314 / bardecoder

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

Unable to read 200x200 QR Code with empty center space #9

Open oceanlewis opened 5 years ago

oceanlewis commented 5 years ago

Seems that QR Codes that have an empty center space to them are not readable by bardecoder.

test-small-inline

It's readable on my phone, so at least it's valid to whatever library that is using. Let me know if you need more information from me :)

Edit: It also seems that larger QR Codes with the same empty center space also fail to be read.

oceanlewis commented 5 years ago

It seems that it's related to the number of characters in the QR Code. Here's two images that differ by one character. The first is unreadable by bardecoder, the second is. Both are readable by my phone.

The unreadable one: unreadable

The readable one: readable

piderman314 commented 4 years ago

Hey, thanks for the report. I'm a little bit busy the coming days but I'll have a look next week.

KyleMaas commented 4 years ago

It looks like this is coming from decode::qr::correct. eq is being passed to solve() as an empty list, and is triggering solve() to return None due to num_eq == 0. Digging further...

locs is also an empty list. This is apparently because in every place find_locs() checks, it gets a check value mismatch. The check values are all nonzero integers: 179, 32, 8, 136, 108, 243, 50, 43, etc.

What does this mean? I have no idea. I don't know enough about QR code decoding to understand how this all works, and there are very few comments in this section of code. But hopefully the extra information will help track it down by someone more knowledgeable than me.

@davidarmstronglewis Do you mind if I include a unit test which includes your failing barcode? Don't know if you got it from somewhere or generated it yourself, but I figured I'd better ask before I go including it in the codebase on my fork.

oceanlewis commented 4 years ago

@KyleMaas Please do! I'm not working on the project where I ran into this issue anymore, but I'd be happy to see this work continue to evolve and improve 🙂

chenyukang commented 2 years ago

wechat2 emm, this kind of QR code also can not be detected:

result: [Err(QRError { msg: "Could not calculate error distances" })]