Ram*_*man 3 java image image-processing zxing
我正在尝试使用 zxing 库(GenericMultipleBarcodeReader)读取二维数据矩阵条码。我在单个图像上有多个条形码。
问题是 zing 阅读器的效率非常低,它从图像 1.png 中识别出 1 个条形码,而从具有 48 个条形码的图像 2.png 中识别不出条形码。有没有办法获得 100% 的效率或任何其他导致 100% 的库
我读取条形码的代码是:
public static void main(String[] args) throws Exception {
BufferedImage image = ImageIO.read(new File("1.png"));
if (image != null) {
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
DataMatrixReader dataMatrixReader = new DataMatrixReader();
Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
GenericMultipleBarcodeReader reader = new GenericMultipleBarcodeReader(
dataMatrixReader);
Result[] results = reader.decodeMultiple(bitmap, hints);
for (Result result : results) {
System.out.println(result.toString());
}
}
}
Run Code Online (Sandbox Code Playgroud)
我使用的图像是:

请帮助解决此问题。
谢谢
这种方式不太行。它不会读取网格中的条形码,因为它假设它可以以与网格不兼容的某种方式切割图像。您必须编写自己的方法来将图像切割成可扫描区域。
数据矩阵解码器也假设图像的中心在条形码内部。这是您需要将图像预切成圆柱体周围的正方形然后扫描的另一个原因。那么它应该可以很好地工作。
| 归档时间: |
|
| 查看次数: |
7796 次 |
| 最近记录: |