无法让zxing识别qrcodes

时间:2014-03-29 11:16:38

标签: java zxing qr-code

我正在开发用于解码qrcodes的Java应用程序,如下所示:qrcode1 在以下代码中调用reader的解码方法时,我总是得到com.google.zxing.NotFoundException。

public String decode(File img) throws QRCodeException {
    Result result;
    BinaryBitmap binaryBitmap;
    try (FileInputStream fis = new FileInputStream(img)) {

        Map<DecodeHintType, Object> decodeHints = new HashMap<>();
        decodeHints.put(DecodeHintType.TRY_HARDER, TRUE);
        decodeHints.put(DecodeHintType.ASSUME_GS1, TRUE);

        binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(ImageIO.read(fis))));

        MultiFormatReader reader = new MultiFormatReader();
        result = reader.decode(binaryBitmap, decodeHints);
        BarcodeFormat barcodeFormat = result.getBarcodeFormat();
        System.out.println("QR Code : " + result.getText());
        return result.getText();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new QRCodeException();
    }
}

我还尝试使用Android应用检查这些代码。他们中的大多数人都不认识这些qrcodes。只有一个应用程序可以提供正确的NeoReader结果。

你知道如何让zxing得到这些qrcodes吗?

1 个答案:

答案 0 :(得分:0)

这不是有效的二维码,至少不符合现代规范。它是25x25,应该是版本2,但在右下角缺少对齐模式。