2013-11-01 68 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