react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

✨ Support retrieving raw binary data from QR codes

Open ltrel opened this issue 1 year ago • 3 comments

What feature or enhancement are you suggesting?

Currently, if the data inside of the code cannot be decoded into text then no value can be retrieved at all. It would be nice to have something similar to the API provided in https://github.com/cozmo/jsQR which provides both the decoded text and raw binary representation.

What Platforms whould this feature/enhancement affect?

iOS, Android

Alternatives/Workarounds

For the time being this can be achieved using frame processors, however out of all the native plugins listed at https://react-native-vision-camera.com/docs/guides/frame-processor-plugins, the two which seem like they might support this are either deprecated (https://github.com/rodgomesc/vision-camera-code-scanner/tree/master) or rely on a proprietary library (https://github.com/xulihang/vision-camera-dynamsoft-barcode-reader)

Additional information

ltrel avatar Feb 16 '24 12:02 ltrel

Adding some preliminary research

This seems like it shouldn't be too hard to pull of on Android and is supported by the MLKit Vision API. I'm less familiar with the IOS side of things and nothing I'm googling is really jumping out at me.

I'm probably a little out of my depth here but I'm willing to have a go at implementing this if anyone can offer guidance (and has any idea whether this is possible on IOS)

ltrel avatar Feb 16 '24 12:02 ltrel

good feature request - but why would you need the raw data?

mrousavy avatar Feb 16 '24 13:02 mrousavy

My use case is using QR codes as a sort of 'cute and tangible' offline way of exchanging data between app users. Since they're obviously pretty limited in the amount of data they can store, I've made up a binary format to store the data more compactly.

However, after a lot more digging through Stack Overflow threads, and various project documentations, it seems like support for using QR codes in this way is a little limited across the board. The ISO standard makes no mention of it and is entirely focused on various text encodings. Even the so-called "Byte Mode" really just means "a text encoding which happens to have 8-bit wide characters".

So it seems like it's really up to individual tools to decide whether they want to support a way of short-circuiting the whole decoding process like this. For example, ZBar only added an option for this in 2019 in response to this issue

ltrel avatar Feb 17 '24 00:02 ltrel

Closing this for now since I've been able to put together a basic frame processor plugin for this on Android for what I need.

ltrel avatar Feb 27 '24 01:02 ltrel

but why would you need the raw data?

The original use case for the feature was encoding 4096 bit RSA secret keys as QR codes so they could be printed out, stored in a safe and then quickly restored via laptop camera.

Others have since then found rather creative uses for it:

matheusmoreira avatar Mar 04 '24 17:03 matheusmoreira

It seems like @gev2002's react-native-vision-camera-v3-barcode-scanner supports getting raw values from barcodes, and uses MLKit on both iOS and Android :)

mrousavy avatar Apr 02 '24 12:04 mrousavy

another feature request created here btw: https://github.com/mrousavy/react-native-vision-camera/issues/2701

mrousavy avatar Apr 02 '24 12:04 mrousavy