Open Rampagy opened 1 month ago
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.
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?
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.
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.
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:
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:
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)
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