2013-11-01 125 views
0

我試圖從圖像解碼qrcode,但zxing返回未發現的異常 使用我的手機從屏幕掃描的同一圖像成功解碼:如何提高此文件的質量以允許(或其他Java庫)解碼 我沒有聲望,所以我不能上傳圖像:示例圖像是在地址 上一個鏈接編輯使用zxing解碼qrcode

我想解碼它與以下代碼

Reader xReader = new QRCodeReader(); 

BufferedImage dest = ImageIO.read(imgFile); 
LuminanceSource source = new BufferedImageLuminanceSource(dest); 

BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); 
Vector<BarcodeFormat> barcodeFormats = new Vector<>(); 
barcodeFormats.add(BarcodeFormat.QR_CODE); 

HashMap<DecodeHintType, Object> decodeHints = new HashMap<>(3); 
decodeHints.put(DecodeHintType.POSSIBLE_FORMATS, barcodeFormats); 

decodeHints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); 

Result result = null; 
result = xReader.decode(bitmap, decodeHints); 

回答

0

這是噪音。不要抖動爲1位單色,或者應用光線模糊濾鏡。

+0

我在哪裏抖動到單色? 我不知道該怎麼做:我以前從來沒有在java下管理過鏡像。 你能幫我一個例子嗎? – user2946593

+0

我已經研究並搜索了一些關於模糊圖像的內容,它起作用了! 謝謝 – user2946593