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

[feature request] Add masking type for QR codes #501

Open
Rampagy opened this issue Oct 9, 2024 · 4 comments
Open

[feature request] Add masking type for QR codes #501

Rampagy opened this issue Oct 9, 2024 · 4 comments

Comments

@Rampagy
Copy link

Rampagy commented Oct 9, 2024

Thanks for creating such a great app!

I was curious if it would be possible display the mask for QR codes.

I did a little searching and it appears there are 8 possible masks to a QR code:
image

The library ZXing C++ has to be able to decipher this mask in order to read the QR code. I guess it's a question of whether or not it provides the mask.

These are the 3 bits that encode the mask:
image

This video from Veritasium describes it really well.
https://youtu.be/w5ebcowAJD8?&t=1612

In this example I believe the mask would be 4 (0b100)
image

I did some quick searching and this was the closest I could find, but unfortunately it only returns if it's a valid mask, but not actually the mask. The maskIndex referenced in that function would be it.
https://github.com/zxing-cpp/zxing-cpp/blob/master/core/src/qrcode/QRDataMask.h#L23-L43

@markusfisch
Copy link
Owner

Thanks for using the app! I had watched that Veritasium video too 😉

As you already found out, the mask type isn't currently exposed in the DecodeResult, unfortunately. But of course it's possible, and it would be very helpful for the reconstructed QR Code the app is showing on the result screen.

So I made this PR, and if it gets accepted, Binary Eye will be able to show the exact mask type.

@axxel
Copy link

axxel commented Oct 10, 2024

I've watched it with great pleasure as well ;). May I ask what the use case is for recreating a scanned code? And you want to recreate the original (error corrected) symbol, not show the one that the library actually saw?

@markusfisch
Copy link
Owner

Reproducing the scanned QR code as accurately as possible naturally creates the confidence (or rather illusion 😉) that the reproduction exactly matches the original. Of course, irrelevant from a technical perspective, but it's still reassuring.

Then it is sometimes useful for diagnostic and research purposes to see exactly which mask was used by some generator. A niche application, of course, but it's still an interesting detail, I think.

And you want to recreate the original (error corrected) symbol, not show the one that the library actually saw?

Hm, yes, I don't think it would make too much sense to reproduce a symbol with errors 🤔 It's just nice when the reproduction usually matches the original exactly, but I wouldn't want to take this to far. There's also some lingering issue to save the original image of the barcode, and I would rather do something like this to truly keep the original, which would probably serve a slightly different purpose.

@Rampagy
Copy link
Author

Rampagy commented Oct 10, 2024

Then it is sometimes useful for diagnostic and research purposes to see exactly which mask was used by some generator.

This is the basis of my request.

And you want to recreate the original (error corrected) symbol, not show the one that the library actually saw?

I think reproducing it without errors is important. The scenario I envision is scanning a QR code at a restaurant that has faded/weathered/etc... Using the error corrected symbol would allow you to know what the algorithm is correcting the symbol to. Knowing what the bits were corrected to and doing a quick visual scan of the reconstructed symbol to see that it matches the original builds confidence that it's correct.

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