如果解析帶有logo的總報錯
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(); }
網上搜了 說是設置那幾個屬性? 設置了還是報錯? ?圖片是我手機拍的 然后進行截圖解析
2019-09-02
圖片不清楚可能會導致解析時將logo也看成二維碼的黑條一起解析。