Re: [zxing] Cannot draw a bounding box around a QR code recognized by ZXing

743 views
Skip to first unread message
Message has been deleted

Lachezar Dobrev

unread,
May 8, 2019, 5:35:48 AM5/8/19
to ackh, zxing
Please take a look at the https://en.wikipedia.org/wiki/QR_code#Standards.
The green-marked white space around the QR Code is a part of it.
That's a Quiet Zone. The specification says that 4 modules (four
"dots") around the actual content and is required.

Polluting the Quiet Zone will reduce the detection rate to a point
where it may no longer be detected at all.

TLDR; Draw the bounding box 4 modules/dots away from the content.

На вт, 7.05.2019 г. в 17:38 ч. ackh <ack...@gmail.com> написа:
>
> Hi
>
> When attempting to draw a bounding box around a QR code recognized by ZXing, I'm encountering a problem with the coordinates that I receive from ZXing. I have outlined the problem in more details on StackOverflow: https://stackoverflow.com/q/56024707/5548098
>
> Because it is already described there, I'm omitting further details. If this is not how it should be done, please forgive me and let me know so that I can adjust accordingly.
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups "zxing" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to zxing+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/zxing/46bac7ec-346d-4713-a9f4-7489bdf1345c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Lachezar Dobrev

unread,
May 8, 2019, 6:04:03 AM5/8/19
to ackh, zxing
Oh, that's not what you asked. Sorry about that!

I've had similar problems a while ago. I was only handling
ResultPointCallback in Android, but it might be similar to your
problem.
The result points are the (rough) centre of the finder patterns and
the bottom-right alignment pattern. That is they do not represent the
QR Code boundaries, but rather the key points of the QR Code: the
three position keys and the outer-most alignment pattern. See the
attached example of what the four corners are.
qr-x.png

Lachezar Dobrev

unread,
May 8, 2019, 6:14:43 AM5/8/19
to ackh, zxing
You probably could:
1. Create a perspective correction, and apply it to the result points
- See com.google.zxing.qrcode.detector.Detector.createTransform(ResultPoint,
ResultPoint, ResultPoint, ResultPoint, int)
2. Convert to square:
a) Move the bottom-right alignment pattern a bit out
- add 3 module-width to the X
- add 3 module-width to the Y
b) Calculate the expected position from the 3 other corners
3. Increase the size of the bounding box
- Add 4 module-width on all sides
4. Apply reverse perspective correction to get the positions in the
original image.

HTH
Reply all
Reply to author
Forward
0 new messages