Title
Java: невозможно декодировать определенный QR-код с помощью ZXing или BoofCV
Image
myQR
Body
Я пытаюсь декодировать сложный QR-код на Java, но ни ZXing, ни BoofCV может прочитать его правильно.
Минимальный воспроизводимый пример
import com.google.zxing.*;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.HybridBinarizer;
import boofcv.io.image.ConvertBufferedImage;
import boofcv.struct.image.GrayU8;
import boofcv.factory.fiducial.ConfigQrCode;
import boofcv.abst.fiducial.QrCodeDetector;
import boofcv.struct.qrcode.QrCode;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.List;
public class QRTest {
public static void main(String[] args) throws Exception {
BufferedImage img = ImageIO.read(new File("myQR.png"));
// ZXing attempt
try {
Result result = new MultiFormatReader().decode(
new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(img))));
System.out.println("ZXing: " + result.getText());
} catch (Exception e) {
System.out.println("ZXing failed: " + e.getMessage());
}
// BoofCV attempt
GrayU8 gray = ConvertBufferedImage.convertFromSingle(img, null, GrayU8.class);
QrCodeDetector detector = new QrCodeDetector(ConfigQrCode.defaultConfig());
detector.process(gray);
List codes = detector.getDetections();
if(codes.isEmpty()[enter image description here]
System.out.println("BoofCV failed to detect any QR codes.");
else
codes.forEach(qr -> System.out.println("BoofCV: " + qr.message));
}
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... -or-boofcv