I try to use Zxing to decode Aztec code.
I use code from SO answer. Here is a part of it:
public static String readQRCode(String filePath, String charset, Map hintMap)
throws FileNotFoundException, IOException, NotFoundException {
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(
new BufferedImageLuminanceSource(
ImageIO.read(new FileInputStream(filePath)))));
Result qrCodeResult = new MultiFormatReader().decode(binaryBitmap,
hintMap);
return qrCodeResult.getText();
}
I try to read those image by code above:
But this fails with:
Exception in thread "main" com.google.zxing.NotFoundException
I said - Ok, maybe it's too low quality - so I took GIMP and:
- Erode image with 3x3 mask.
- Take automatic gimp thresholding (binarize image).
That simple pre-processing gave me this:
Maybe it hasn't wonderful quality, but it is simply black and white - is it better? No. I still obtain:
Exception in thread "main" com.google.zxing.NotFoundException
What is strange: almost all Barcode Readers reads both without any problems. For example: NeoReader (Android - mobile phone) reads both from laptop's screen - correctly!
I want to add that absolutely clear images like this from Wiki, are correctly recognized by this code.
Question:
What is wrong with the code above?
How decode this Aztec codes? I can do any preprocessing, but what steps are require?
Please help.
Project details: Java 8, com.google.zxing:core:3.2.1, com.google.zxing:javase:3.2.1