0
我想使用网络摄像头从一张纸上读取QR码,但它一直不合格 - 它不会打印。我一直坚持这个问题好几天了。从网络摄像头读取QR码
这里是我的代码:
公共无效imageUpdated(形象画像) {
LuminanceSource ls = new BufferedImageLuminanceSource((BufferedImage)image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(ls));
QRCodeReader qrReader = new QRCodeReader();
try {
Result result = qrReader.decode(bitmap);
System.out.println("QR Code data is: "+result.getText());
} catch (NotFoundException e) {
// TODO Auto-generated catch block
System.out.println("--------");
} catch (ChecksumException e) {
// TODO Auto-generated catch block
System.out.println("--------");
} catch (FormatException e) {
// TODO Auto-generated catch block
System.out.println("--------");
}
qrReader.reset();
}
这段代码看上去很奇怪的,你的人?任何帮助表示赞赏,谢谢:)
这取决于图像质量。您可以尝试在解码方法中添加指令'try harder':Map hints = new TreeMap <>(); \t \t hints.put(DecodeHintType.TRY_HARDER,null);结果结果= qrReader.decode(位图,提示);' –
LibertyPaul
它仍然不起作用..但是,谢谢你的回答:) – Jacob
你能提供你想要解码的图像的例子吗? – LibertyPaul