【发布时间】:2013-11-01 22:31:54
【问题描述】:
我正在尝试从图像中解码二维码,但 zxing 返回未找到异常 用我的手机从屏幕上扫描的同一张图像成功解码:如何提高此文件的质量以允许通过 zxing(或其他 java 库)对其进行解码 我没有声誉,所以我无法上传图片:示例图片在地址 上一个链接已编辑
我正在尝试使用以下代码对其进行解码
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);
【问题讨论】: