/**
* Created by leno on 2018/2/9.
* 条形码识别
*/
public class ZxingUtil {
public static String decode(String imgPath) throws IOException, NotFoundException {
BufferedImage image = null;
Result result = null;
image = ImageIO.read(new File(imgPath));
if (image == null) {
System.out.println("the decode image may be not exit.");
}
Map<DecodeHintType, Object> hints = new HashMap<>();
hints.put(DecodeHintType.CHARACTER_SET, "utf-8");
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
hints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE);
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
result = new MultiFormatReader().decode(bitmap, hints);
return result.getText();
}
}
web端利用ZXing进行条形码识别
猜你喜欢
转载自blog.csdn.net/qq_32090861/article/details/80948919
今日推荐
周排行