【发布时间】:2014-03-29 11:16:37
【问题描述】:
我正在开发用于解码二维码的 Java 应用程序,如下所示:qrcode1 在下面的代码中调用阅读器的解码方法时,我总是得到 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 应用检查这些代码。他们中的大多数人不认识这些二维码。只有一个应用程序可以提供正确的结果 NeoReader。
你知道如何让 zxing 使用这些二维码吗?
【问题讨论】: