I'm using GoogleMobileVision/Barcode detector in my Swift 3.1 project using the following code:
GMVDetector(ofType: GMVDetectorTypeBarcode, options: nil)
but in the log it shows:
It seems that GoogleMobileVision in iOS is closed source so I cannot really see what's happening on the implementation side
Any thoughts on what possibly is happening here?
I think you need to put some optional value of barcode type like EAN13 or QRcode instead of nil.
var detector = GMVDetector()
let options:[AnyHashable: Any] = [GMVDetectorBarcodeFormats : GMVDetectorBarcodeFormat.EAN13.rawValue]
self.detector = GMVDetector.init(ofType: GMVDetectorTypeBarcode, options: options)
Edited - Solved
The problem was this piece of code (as @Developer said)
let detectorOptions = [
GMVDetectorBarcodeFormats : GMVDetectorBarcodeFormat.qrCode.rawValue
]
I have the same problem with no success, I don't know what's going on.
It looks that it has to be anything so simple but I think I tried every way to instantiate this. I searched for swift examples but I dind't find anything useful.
var barcodeDetector : GMVDetector?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let detectorOptions = [
GMVDetectorBarcodeFormats : [
GMVDetectorBarcodeFormat.qrCode.rawValue
]
]
self.barcodeDetector = GMVDetector(ofType: GMVDetectorTypeBarcode, options: detectorOptions)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
override func viewDidAppear(_ animated: Bool) {
if let image = UIImage(named: "QRTest.png") {
if let barcodes = self.barcodeDetector!.features(in: image, options: nil) {
for barcode in barcodes {
print("\(barcode.description)")
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With