I am trying to make an app which reads QR images and get the data from the image. I am using the latest version of the google machine learning kit for scan barcodes and followin
So if we look at the code:
Why would this not work? Step 2 is async so it takes say a fraction of time before it is executed but in the meantime, step 3 kicks in and clear the image - no image to detect. The solution is to use addOnCompleteListener
to close the image:
scanner.process(image)
.addOnFailureListener { // Some code}
.addOnSuccessListener { // Some more code}
.addOnCompleteListener {
// Close the image
imageProxy.close()}
BTW this got me the first time too and we are thinking about adding better debug message than "Image is already close".