dlbeer / quirc

QR decoder library
Other
882 stars 286 forks source link

Fix issue #72 grouping and make gridsize determination more robust. #79

Closed JaapHaitsma closed 3 years ago

JaapHaitsma commented 4 years ago

This pull request should not be applied as is as it has two candidates for improving the determining of the grid size. Sending you this pull request to get your feedback on where do you want to go. After that I can clean it up

First this patch makes grouping more robust in case there are multiple QR codes. It detects now all the codes in the image of Issue #72. It does this by trying to extract a QR code of all sets of capstones that are on a grid that is square enough. E.g. in the image of Issue #72 it finds 15 possible candidates.

What I also noticed is that the gridsize determination is not very robust. It can happen that there is some noise in the line to determine the timing scan. I made it more robust by requiring at least a run lenght of 2. However if the resolution of image with the QR is low runs might be shorter than 2.

I wrote the function measure_grid_size which measure the distance between capstones. As a capstone has a length of 7 it is trivial to calculate what the approx. grid size is. In my testing this seems more robust than the current method and it reduces also the number of lines.

I left both the improved of version of the timing scan and the new measure_grid_size function in the patch such that you can easily try out both if you want.

Looking forward to your comments

kaworu commented 3 years ago

Thank you @JaapHaitsma for the PR. Admittedly, I lack context about the changes. @dlbeer could you take a look please?

dlbeer commented 3 years ago

This looks like a really good idea - apologies for taking so long to get back to you. I assume the codes that you had problems with in the original issue are now working as a result of these changes?

If so, and you're happy to give us pull requests for these two changes I think we should merge them in.

JaapHaitsma commented 3 years ago

Put the update pull request in https://github.com/dlbeer/quirc/pull/109 So closing this one