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