michaeltroger / greenpass-android

Green Pass PDF Wallet Android App
https://play.google.com/store/apps/details?id=com.michaeltroger.gruenerpass
GNU General Public License v3.0
73 stars 3 forks source link

Aztec recognition capability #32

Closed DrNion closed 5 months ago

DrNion commented 2 years ago

First of all thanks for the nice little app!

Since some companies use weird QRCode-ish codes which obviously cannot be recognized, it would be an awesome addition to your app to optionally cut any code (or any other part) manually out of the PDF for the preview.

Edit: ...to support Aztec Code.

michaeltroger commented 2 years ago

Hi!

THX for your feedback/suggestion! I experienced a similar problem with Austrian ÖBB train tickets. Their "QR code" has some symbol in the centre. Additonally it doesn't have the 3 boxes at 3 corners as the standard suggests. Anyhow it's not being recognized as QR code.

I'm using here the ZXing library for reading QR codes. ZXing is the most popular library out there. Not sure why it's not capable of detecting those variations...

Regarding cutting a part out, I must say that I would prefer a solution for the root cause. I can investigate if there is a better way to detect "special" forms of QR codes. While technically for sure possible, the cutting would be quite some effort to implement, and I'm not sure there is so much demand for such a feature that would justify the time effort.

How does your problematic "QR code" look like? Is it also one with symbol in the centre, without corner marks or what is special about it?

michaeltroger commented 2 years ago

Seems like there are at least 2 additional formats that look kind of similar to QR codes: https://en.wikipedia.org/wiki/Aztec_Code https://en.wikipedia.org/wiki/Data_Matrix Seems the one from ÖBB is Aztec. That explains why it's not being recognized. Does yours look similar to one of those?

DrNion commented 2 years ago

Yes kind of, it's one from the Deutsche Bahn. But I tried to scan their Code and my scanner didn't recognized it. I will look it up, maybe it is still a known format and nothing proprietary.

DrNion commented 2 years ago

Seems to be Aztec: https://stackoverflow.com/questions/34423303/need-help-decompressing-zlib-data-stored-in-aztec-barcode-deutsche-bahn-ticket There you can find a ticket example too.

michaeltroger commented 2 years ago

Since Aztec seems to be wildly used for public transport tickets I'll try to support it in a future version. I'll come back to you for trying it out. ZXing has some dedicated API for it

DrNion commented 2 years ago

Ok, I changed the Titel :)

michaeltroger commented 2 years ago

Hi @DrNion , sorry for the late response. I concretely tried to implement this feature, however after careful consideration, I decided to not invest in this topic any longer. I can simply not assure it works good enough on a variety of devices, without investing a lot of time.

Unfortunately it's not as easy as just searching the image for a barcode with a barcode library. In reality the image resolution is too low for detecting Aztec codes (feel free to try out the changes of the linked PR).

Now I had different solutions in mind:

Sorry for not having better news.

External help is welcome for implementing this though (please align with me before investing too much time).

rugk commented 2 years ago

I already have now issues on low-end devices that run out of memory. So this is not really an option.

Uff bad thing. However, can't you try to implement some kind "streamed processing" where you automatically "divide up" the image into squares (proportionally to the initial image size) and process each square separately? And then throw it away in memory… Oh I just see the flaw here:

Just some ideas/brainstorming for some approaches… (Note I am no Android dev, so I do not know the limitations of the platform in detail.)

I see the UX challenges of the second approach, and in contrast to that I guess a few seconds of waiting for some complexer algorithm should be fine.


Do other scanner apps that support aztec code have the same issues? Likely not, because you as a user are expected to choose the size there, as it seems.

Btw for me being curious: Why is processing QR codes not a problem, but Aztec codes is actually?

Because that is used really really widely for public transport

michaeltroger commented 5 months ago

Version 4 now supports Aztec code experimentally