Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image with a QR and high frequency components does not decode #122

Open
gnusuari0 opened this issue Jun 8, 2020 · 4 comments
Open

Image with a QR and high frequency components does not decode #122

gnusuari0 opened this issue Jun 8, 2020 · 4 comments

Comments

@gnusuari0
Copy link

gnusuari0 commented Jun 8, 2020

Example: https://pbs.twimg.com/media/EZIyEWrXQAMfNQs?format=jpg&name=4096x4096

If blurring is applied to the original image, Binary Eye is capable of decoding the QR code.
A filter needs to be applied to smooth images. Smaller codes will need the phone to be closer or reduce the amount of blurring applied in order to not lose detail. A threshold should be computed to know the amount of blurring needed, if possible.

@SuperSandro2000
Copy link

@gnusuari0
Copy link
Author

gnusuari0 commented Jun 9, 2020

I made a manual filtering with the GIMP.
I first applied an average blur. Diamond neighbourhood and a radius of 12.
Then I binarized the image using the threshold filter on the RGB channel, with the lower input threshold set at 28.

qr-filtered

In this case, if you first binarize and then you do the average blur to remove the white spots, the radius of the average blur can be lower.

Another option I tested was to reduce the image size to 1/10th of the width and height, and resize it to the original size again (supersampling). Then binarize with threshold at 56. It also works.

@markusfisch
Copy link
Owner

markusfisch commented Jun 9, 2020

Well, Binary Eye already downsamples the camera frame to 75% (see here) which is kind of equivalent to applying a slight blur (the downsampling also results in less data to process what's good for performance on bad devices).

Looking at your samples (you should really have a quiet zone around your QR Codes by the way), I believe the best solution would be to apply an Adaptive Threshold algorithm (something like this).

There are a couple of Adaptive Threshold implementations for RenderScript available so it would be quite easy to try this. And Binary Eye has device tests, so it's easy to tell when a change breaks something.

@gnusuari0
Copy link
Author

gnusuari0 commented Jun 9, 2020

I was talking about blurring because I supposed Binary Eye uses a local threshold algorithm for binarization (https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/common/HybridBinarizer.java) which is supposed to overcome the problems this sample has: being a high frequency image.
Anyways, I hope these samples are useful for improving the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants