如果解析带有logo的总报错

来源:6-3 使用zxing进行二维码解析

dqpi_lyy

2018-12-25 10:18

com.google.zxing.NotFoundException
	try {			MultiFormatReader multiFormatReader = new MultiFormatReader();						File file = new File("D:/jar/jk.jpg");						BufferedImage image =  ImageIO.read(file);			Map<DecodeHintType, Object> tmpHintsMap = new EnumMap<DecodeHintType, Object>(			        DecodeHintType.class);			// 解码设置编码方式为:utf-8,			tmpHintsMap.put(DecodeHintType.CHARACTER_SET, "utf-8");			//优化精度			tmpHintsMap.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);			//复杂模式,开启PURE_BARCODE模式			tmpHintsMap.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE);						BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(image)));			Result result = multiFormatReader.decode(binaryBitmap, tmpHintsMap);			System.out.println("二维码内容 : " +result.toString());			System.out.println("二维码格式 : " +result.getBarcodeFormat());			System.out.println("二维码文本 : " +result.getText());		} catch (NotFoundException e) {			// TODO Auto-generated catch block			e.printStackTrace();		} catch (IOException e) {			// TODO Auto-generated catch block			e.printStackTrace();		}

网上搜了 说是设置那几个属性  设置了还是报错   图片是我手机拍的 然后进行截图解析

https://img3.mukewang.com/5c2193660001c05910801104.jpg

写回答 关注

1回答

  • 墨染千城白
    2019-09-02 17:52:07

    图片不清楚可能会导致解析时将logo也看成二维码的黑条一起解析。

Java生成二维码

二维码无处不在,自己动手用Java生成二维码,三种生成方式任你选

84564 学习 · 224 问题

查看课程

相似问题