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

✨ Support export of rawBytes/Data in barcode scanning #2701

Open
2 tasks done
tastydev opened this issue Mar 28, 2024 · 2 comments
Open
2 tasks done

✨ Support export of rawBytes/Data in barcode scanning #2701

tastydev opened this issue Mar 28, 2024 · 2 comments
Labels
✨ feature Proposes a new feature or enhancement

Comments

@tastydev
Copy link

tastydev commented Mar 28, 2024

What feature or enhancement are you suggesting?

There are Usecases where the rawBytes of the barcode/datamatrix/qr-code have to be interpreted as they are meant to be interpreted. Not every barcode data is utf8 encoded, so it would be great to export the rawBytes and let the application which retrieves them, decode with their preferred character encoding.

I.e i need to parse/decode xml data with the character encoding latin1 but i can't do it consistently as the default barcode scan displayValue encodiing is utf8 inside MLKit and iOS which breaks the xml if i.e ä,ü,ö appear inside the bytes as they are encoded differently on utf8 (bytes per character)

See Alternatives/Workarounds for a deep dive

What Platforms whould this feature/enhancement affect?

iOS, Android

Alternatives/Workarounds

On Android it is easily possible to export the read bytes with https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/common/Barcode#getRawBytes()
as MlKit already stores them.

On iOS i couldn't find an easy way to retrieve the rawBytes yet. I know the bytes have to be there but i can't find the reference. Maybe someone has an Idea?
If it is absolutly not possible to retrieve the rawBytes through the apple iOS sdk maybe it would be needed to switch to MlKit also for iOS and use their swift api to retrieve https://developers.google.com/ml-kit/reference/swift/mlkitbarcodescanning/api/reference/Classes/Barcode#rawdata

Additional information

@tastydev tastydev added the ✨ feature Proposes a new feature or enhancement label Mar 28, 2024
@mrousavy
Copy link
Owner

mrousavy commented Apr 2, 2024

I searched for similar feature requests in this repository and found none.

This is a duplicate of #2572.

Anyways - we can leave this open, but there is no way to get the raw binary data of a QR code on iOS using the iOS APIs for barcode reading.

I will not replace the iOS implementation with MLKit - I explained that in a lot of other issues already, the iOS implementation is a "free" extra Camera output, whereas using MLKit would require to be put into a Frame Processor.

So if I use MLKit on iOS, you'd need to enable Frame Processors, download the additional dependency, and potentially also introduce higher CPU usage, thermal usage and RAM usage.

I believe the iOS APIs are much more optimized and extremely lightweight. Also, no dependency on Google APIs.

@mrousavy
Copy link
Owner

mrousavy commented Apr 2, 2024

If you absolutely need binary data - just use a Frame Processor Plugin, as mentioned in #2572. You can easily use MLKit's APIs from Frame Processor Plugins with just a few tiny lines of native code :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature Proposes a new feature or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants