I am new to zxing library
and so to QR Codes. Using zxing library 1.7
I have generated QR codes, those QR codes are sticked to the papers and papers are later scanned in a PDF. I do have created client program of course using zxing
library itself which reads this scanned PDF page by page and shows QR Code text if any QR Code is found on a page. I am trying to read multiple QR from each page of scanned PDF.
Though I am able to read some QR code the result is inconsistent. Means I am able to read some QR code in a PDF page while some of them are not getting recognized by my client program. I have gone through other threads for same topic. and modified my code a little though I am not able to get 100% result.
Here is my code snippet to give more idea about what I am exactly doing.
Note: I am using PdfReaderContentParser of itext PDF library to extract scanned image of each pdf page as shown here
private void extractBarcodeText(BufferedImage bufferedImage) {
try {
Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
hints.put(DecodeHintType.TRY_HARDER, BarcodeFormat.QR_CODE);
LuminanceSource source = new com.google.zxing.client.j2se.BufferedImageLuminanceSource(bufferedImage);
BinaryBitmap bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source));
List<String> innerTextList = new ArrayList<String>();
QRCodeMultiReader multiReader = new QRCodeMultiReader();
Result[] results = multiReader.decodeMultiple(bitmap, hints);
for (int k = 0; k < results.length; k++) {
String text = results[k].getText();
innerTextList.add(text);
System.out.println("#################### Rendered Text from Image #################"+ " " + text);
}
} catch (NotFoundException e) {
e.printStackTrace();
}
}
I have tried many combinations but no luck. Is it due to poor image quality ? But then how some images are getting recognized and some remains as a mystery :(
Do anyone know what should I do to overcome this issue? Here is one sample image at bottom for your reference, in that first image is getting recognized using above code where second one (HRA) is not.!