如果解析帶有l(wèi)ogo的總報(bào)錯(cuò)
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); //?解碼設(shè)置編碼方式為:utf-8, tmpHintsMap.put(DecodeHintType.CHARACTER_SET,?"utf-8"); //優(yōu)化精度 tmpHintsMap.put(DecodeHintType.TRY_HARDER,?Boolean.TRUE); //復(fù)雜模式,開啟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("二維碼內(nèi)容?:?"?+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(); }
網(wǎng)上搜了 說是設(shè)置那幾個(gè)屬性? 設(shè)置了還是報(bào)錯(cuò)? ?圖片是我手機(jī)拍的 然后進(jìn)行截圖解析
2019-09-02
圖片不清楚可能會(huì)導(dǎo)致解析時(shí)將logo也看成二維碼的黑條一起解析。