fix: Only close image once

This commit is contained in:
Marc Rousavy 2023-12-12 11:19:42 +01:00
parent 9600a38398
commit df32d2c5e9
No known key found for this signature in database
GPG Key ID: 83BEF0F19E8F5321

View File

@ -53,15 +53,11 @@ class CodeScannerPipeline(
val inputImage = InputImage.fromMediaImage(image, Orientation.PORTRAIT.toDegrees()) val inputImage = InputImage.fromMediaImage(image, Orientation.PORTRAIT.toDegrees())
scanner.process(inputImage) scanner.process(inputImage)
.addOnSuccessListener { barcodes -> .addOnSuccessListener { barcodes ->
image.close()
isBusy = false
if (barcodes.isNotEmpty()) { if (barcodes.isNotEmpty()) {
callback.onCodeScanned(barcodes, CodeScannerFrame(inputImage.width, inputImage.height)) callback.onCodeScanned(barcodes, CodeScannerFrame(inputImage.width, inputImage.height))
} }
} }
.addOnFailureListener { error -> .addOnFailureListener { error ->
image.close()
isBusy = false
callback.onError(error) callback.onError(error)
} }
.addOnCompleteListener { .addOnCompleteListener {