Wednesday 27 January 2021

Google ML Kit - Barcode API - Orientation of the detected QR code

I'm using Google ML Kit (formerly The Mobile Vision API)

I'm trying to figure out the angle/orientation or "the way it is facing" of the scanned QR code.

The positions of the 3 squares of the QR Code (top left, top right and bottom left) is what I'm interested in. Using their positions, I can figure out its orientation. But the cornerPoints property of BarcodeDetector returns 4 corners of the overall QR code square. (And they seem to be in a random order in the array)

Here's how I do it:

Frame frame = new Frame.Builder().setBitmap(bmp).build();
SparseArray<com.google.android.gms.vision.barcode.Barcode> barcodes = barcode_detector.detect(frame);

if (barcodes.size() > 0) {
    com.google.android.gms.vision.barcode.Barcode qr = barcodes.valueAt(0);
    android.graphics.Point[] corners = qr.cornerPoints;
}

Is there a way I can learn the information I want with this API? I'm using OpenCV to figure out that information as of now but Google API is far superior and faster when it comes to actually detecting and reading QR Codes, so I'd like to only use that if possible.



from Google ML Kit - Barcode API - Orientation of the detected QR code

No comments:

Post a Comment