【发布时间】:2014-06-16 11:01:21
【问题描述】:
我正在尝试使用google.zxing 读取二维码。以下是我曾经阅读过的代码。
Result result = null;
BinaryBitmap binaryBitmap;
FileInputStream pngInput = null;
try {
pngInput = new FileInputStream("D:\\TestQR.png");
binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(ImageIO.read(pngInput))));
result = new MultiFormatReader().decode(binaryBitmap,null);
}catch (Exception e) {
throw e;
}finally {
if(pngInput != null) {
pngInput.close();
}
}
System.out.println(result.getText());
现在上面的代码对某些图像工作正常,并为其中一些图像抛出 NullPointerException。我检查了该图像,但该图像完全可以使用移动应用程序读取。 是否有任何其他第三方 API 可以解决此问题?上述行中是否需要任何代码更改?
这是对我造成问题的图像。
【问题讨论】:
-
嗨。你能提供堆栈跟踪吗?此外,图像的副本会很有用。
-
我已经用图片编辑了问题。