Unable to detect QRCode from image using MLKit

695 Views Asked by At

I am using MLKIt for detect QRCode from image. for andrid it is working proper, for ios I am using below pods

pod 'GoogleMLKit/BarcodeScanning'

Here is sample code detect QRcode from image which picked from gallery. every time features array comes empty.

Sample image

let format: BarcodeFormat = BarcodeFormat.all
let barcodeOptions = BarcodeScannerOptions(formats: format)

        
let visionImage = VisionImage(image: image)
visionImage.orientation = image.imageOrientation
        
let barcodeScanner = BarcodeScanner.barcodeScanner(options: barcodeOptions)
barcodeScanner.process(visionImage) { features, error in
  guard error == nil, let features = features, !features.isEmpty else {
    // Error handling
    return
  }
  // Recognized barcodes
  print("Data :: \(features.first?.rawValue ?? "")")
  
}
1

There are 1 best solutions below

0
On

We noticed this may happen when there are no padding around the QR code, I also tried to add some padding to it:padded QR Code and it works after that. Could you confirm that it works?

On the other side, ML Kit is also working on a public document on this limitation. Thanks for reporting this.

Julie from ML Kit team