Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Vision Barcode API - read custom QR code with binary data

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?

Edit:

This is an absolutely valid QR code, which cannot be read by Vision API, although it carries 1024 bytes of data:

enter image description here


QR Codes - raw binary data is related, but it doesn't solve my problem.

like image 241
vojta Avatar asked Nov 24 '16 14:11

vojta


People also ask

Can there be 2 identical QR codes?

Are QR Code patterns the same for identical data? Even if two QR Codes store identical data, the pattern might or might not be different depending on the QR Code generator used. The primary reason for the change is due to the internal expression of the QR Code (numeric code, alphanumeric code, and so on).

How do I get my Android to recognize QR codes?

On your compatible Android phone or tablet, open the built-in camera app. Point the camera at the QR code. Tap the banner that appears on your Android phone or tablet. Follow the instructions on the screen to finish signing in.

How do I decode a QR Code?

QR Code readingSimply select an area with a QR Code and the program will automatically scan it. You can scan QR codes from websites, documents, movie files – you name it. You can also select an image file that contains a QR Code and the program will locate it automatically and decode it.


1 Answers

I think you need to write some of the implementation yourself. As I can clearly see in the API that the rawData is held by String which simply does not ensure the integrity of your binary data type.

I will write my own BarcodeDetector with my own BarCode object with byte[] as data type for rawData coming from QR-Code and override detect() method to assign the rawData to my BarCode implementation. As your case is very specific to the requirement you should not hesitate to write your own implementation. May be share it on github for others too.

like image 86
Himanshu Chaudhary Avatar answered Oct 20 '22 04:10

Himanshu Chaudhary