android-vision icon indicating copy to clipboard operation
android-vision copied to clipboard

Barcode doesn't provide rawData as a byte array!~

Open 815vojta opened this issue 8 years ago • 12 comments
trafficstars

I use com.google.android.gms.vision.barcode.BarcodeDetector in order to read QR codes. The problem is these codes carry raw binary data; no phone numbers, no URLs, no geopoints... I cannot change these QR codes, because they are generated in a different application.

When I scan these QR codes using Android Barcode API, the resulting Barcode object doesn't allow me to access the raw data, although it must know it!

All I get is "Unknown encoding" message both in rawValue and displayValue properties.

Having a byte[] property instead of two String properties would make more sense, since QR codes can carry general data.

I don't see the point of hiding raw data byte array from developers. Could I somehow extend the BarcodeDetector class or the Barcode class to get what I need?

Thanks a lot!

Related Stack Overflow question

815vojta avatar Nov 25 '16 10:11 815vojta

Yep, I've got a similar use-case with custom aztec codes. Like @815vojta said it would be helpful to provide the raw bytes instead of an error message.

blindgaenger avatar Nov 30 '16 15:11 blindgaenger

Thanks for the feedback.

Unfortunately, there is no way to obtain the raw bytes without adding a new byte[] field since Java requires that Strings contain valid UTF-16. Right now your best option, if you control both the sender and receiver, is to encode your data in a supported character set (e.g. ISO-8859-1).

pchx-zz avatar Nov 30 '16 15:11 pchx-zz

Well, the problem is ISO-8859-1 doesn't work. Please, see the related Stack Overflow question, there you can see my QR code of mode "byte" encoded using ISO-8859-1, which is valid, but unreadable using this Library. All I get is "Unknown encoding" in both rawValue and displayValue, because the byte array wasn't a valid UTF-8 string. However, the default encoding for QR codes should be ISO-8859-1, not UTF-8.

Vojta

Dne 30.11.2016 v 16:26 pchx napsal(a):

Thanks for the feedback.

Unfortunately, there is no way to obtain the raw bytes without adding a new byte[] field since Java requires that Strings contain valid UTF-16. Right now your best option, if you control both the sender and receiver, is to encode your data in a supported character set (e.g. ISO-8859-1).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/googlesamples/android-vision/issues/156#issuecomment-263901635, or mute the thread https://github.com/notifications/unsubscribe-auth/AWo17T0T7PCdTaxTibyjjgoW-7ZGPsIgks5rDZWbgaJpZM4K8Sm4.

815vojta avatar Nov 30 '16 18:11 815vojta

Is there any progress on this topic? Why couldn't you just add a new byte[] field?

Could you please have a look why this code cannot be decoded?

http://stackoverflow.com/questions/40789386/android-vision-barcode-api-read-custom-qr-code-with-binary-data

815vojta avatar Jan 13 '17 10:01 815vojta

+1

bsoja avatar May 24 '17 19:05 bsoja

+1

Wayn0 avatar Jun 19 '17 16:06 Wayn0

+1

kazougaghwaltz avatar Aug 28 '17 20:08 kazougaghwaltz

+1

kotlindroider avatar Mar 06 '18 10:03 kotlindroider

+1

kazougaghwaltz avatar Nov 13 '18 22:11 kazougaghwaltz

+1

Ke4nuReeves avatar Jul 02 '19 15:07 Ke4nuReeves

+1

This is a rather large limitation that needs to be addressed.

rchinoy avatar Sep 13 '19 15:09 rchinoy

+1

mfranzke avatar Nov 07 '19 18:11 mfranzke