Skip to content

Commit

Permalink
[TF][FIX] the inverse color QR code scanned without vision
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai authored and thermatk committed Jun 26, 2021
1 parent 53049f5 commit 0d27018
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.NotFoundException;
import com.google.zxing.PlanarYUVLuminanceSource;
import com.google.zxing.RGBLuminanceSource;
import com.google.zxing.Result;
Expand Down Expand Up @@ -616,7 +617,15 @@ private String tryReadQr(byte[] data, Size size, int x, int y, int side, Bitmap
source = new PlanarYUVLuminanceSource(data, size.getWidth(), size.getHeight(), x, y, side, side, false);
}

Result result = qrReader.decode(new BinaryBitmap(new GlobalHistogramBinarizer(source)));
Result result = null;
try {
result = qrReader.decode(new BinaryBitmap(new GlobalHistogramBinarizer(source)));
} catch (NotFoundException e) {
try {
result = qrReader.decode(new BinaryBitmap(new GlobalHistogramBinarizer(source.invert())));
} catch (NotFoundException ignore) {
}
}
if (result == null) {
onNoQrFound();
return null;
Expand Down

0 comments on commit 0d27018

Please sign in to comment.