Aperture: Pass inverted YUV to MultiFormatReader as well
Might help in some cases?
Change-Id: If762b6192bc72b46144ad4d0029c270bc3facf77
diff --git a/app/src/main/java/org/lineageos/aperture/QrImageAnalyzer.kt b/app/src/main/java/org/lineageos/aperture/QrImageAnalyzer.kt
index 69d5e3d..36c46de 100644
--- a/app/src/main/java/org/lineageos/aperture/QrImageAnalyzer.kt
+++ b/app/src/main/java/org/lineageos/aperture/QrImageAnalyzer.kt
@@ -74,10 +74,16 @@
}
override fun analyze(image: ImageProxy) {
- val binaryBitmap = BinaryBitmap(HybridBinarizer(image.planarYUVLuminanceSource))
+ val source = image.planarYUVLuminanceSource
- runCatching {
- showQrDialog(reader.decodeWithState(binaryBitmap))
+ val reader = runCatching {
+ reader.decodeWithState(BinaryBitmap(HybridBinarizer(source)))
+ }.getOrNull() ?: runCatching {
+ reader.decodeWithState(BinaryBitmap(HybridBinarizer(source.invert())))
+ }.getOrNull()
+
+ reader?.let {
+ showQrDialog(it)
}
image.close()