3

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.

cbt
  • 1,271
  • 1
  • 11
  • 20
  • Why are you trying to detect where the qrcode position markers are located/orientation of the qrcode? – Morrison Chang Jan 26 '21 at 18:27
  • It's not supported currently in MLKit. (You're using Mobile Vision API rather MLKit according to your code snippet) It may be not helpful to your case, but FYI, MLKit returns corner points in clockwise direction starting with top-left. https://developers.google.com/android/reference/com/google/mlkit/vision/barcode/Barcode#public-point[]-getcornerpoints – zhouyi Jan 26 '21 at 22:43
  • @MorrisonChang It's first step of further analysis of the image and easiest way for me to be 100% sure about the rotation of the image is to use the QRs rotation. There are no other clear markers on the image to determine that information. – cbt Jan 27 '21 at 08:45
  • @cbt Decoding a QR code is pretty standard, you can use the code in [zxing - qrcode-detector](https://github.com/zxing/zxing/tree/master/core/src/main/java/com/google/zxing/qrcode/detector) or similar to identify the position detector markers (the 3 squares) from the image of the qrcode. If you are doing image processing, then for performance you may need to be using C/C++ with the NDK to avoid going back and forth through JNI. – Morrison Chang Jan 28 '21 at 01:51
  • 2
    @cbt FYI - although it won't help right now, we will try to output orientation as part of our next major update of the ML Kit API (available in coming months). – Chrisito Jan 29 '21 at 19:09
  • Is there a way to determine the QR orientation from the box corners data of the Barcode? – Lallawmzuala khawlhring Apr 27 '21 at 08:22
  • 1
    @Chrisito has this been implemented yet? So far I'm only seeing the corner points and those are not ordered the same way as the QR code is. – Wolph Nov 28 '21 at 16:33
  • @Chrisito any new ETA for this feature? – Remc4 Feb 24 '22 at 08:47

0 Answers0