I want to read the QR code in attached PDF file. I have tried to directly read the code as well as to use a Detector first. Neither finds any barcode let alone recognizes them. My smartphone easily reads the code. If I manually crop the image just to the QR code it works, but not if other content is on the picture. However I need to handle a barcode and content on a page.
// Code here
BufferedImage image = page.convertToImage(); // Convert PDF page to image
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = null;
bitmap = new BinaryBitmap(new HybridBinarizer(source));
com.google.zxing.qrcode.QRCodeReader qr = new com.google.zxing.qrcode.QRCodeReader();
Result qrCodeResult = qr.decode(bitmap);
// as well as an indirect approach to first find a barcode at all:
// BufferedImage as above
BitMatrix matrix = new HybridBinarizer(source).getBlackMatrix();
com.google.zxing.qrcode.detector.Detector detektiv = new com.google.zxing.qrcode.detector.Detector(matrix);
DetectorResult detResult = detektiv.detect();
Kind Regards
Ernst