问题描述
- 困惑啊!!用zxing读取图片当中的条形码
- 请教个问题:一张图片当中在不固定位置包含有条形码,怎么读取条形码出来呢?怎么读取一张图片中的多个条形码?用zxing读取图片当中的条形码,报错com.google.zxing.NotFoundException。有大神知道的吗?谢谢
解决方案
参考
zxing二维码扫描的流程简析(Android版)
Java Code Examples for com.google.zxing.DecodeHintType
Reading QRCode with Zxing in Java
设置一下TryHarder和PossibleFormats看一下
public static List<string> ScanForBarcodes(string path){ return ScanForBarcodes(new Bitmap(path));}public static List<string> ScanForBarcodes(Bitmap bitmap){ // initialize a new Barcode reader. BarcodeReader reader = new BarcodeReader { TryHarder = true // TryHarder is slower but recognizes more Barcodes PossibleFormats = new List<BarcodeFormat> // in the ZXing There is an Enum where all supported barcodeFormats were contained { BarcodeFormat.CODE_128 BarcodeFormat.QR_CODE //BarcodeFormat. ... ; } }; return reader.DecodeMultiple(bitmap).Select(result => result.Text).ToList(); // return only the barcode string. // If you want the full Result use: return reader.DecodeMultiple(bitmap);}
解决方案二:
谢谢,设置了TryHarder,好了。膜拜大神!
时间: 2024-08-02 04:08:27