使用zxing库读取多个条形码的问题 [英] Issue to read multiple barcodes using zxing library
问题描述
我正在尝试使用zxing库(GenericMultipleBarcodeReader)读取2D数据矩阵条形码。我在一张图片上有多个条形码。
I am trying to read 2D Data matrix barcode using zxing library(GenericMultipleBarcodeReader). I have multiple barcodes on a single image.
问题是zing阅读器的效率非常低,为
识别图像1.png中的1个条形码,图像2.png中没有条形码,其中包含48个条形码。是否有
以任何方式获得100%效率或任何其他库100%
The problem is that the efficiency of the zing reader is very low, it recognizes 1 barcode from image 1.png and no barcode from image 2.png which has 48 barcodes. Is there any way to get 100% efficiency or any other library which results 100%
我读取条形码的代码是:
My code to read barcode is:
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());
}
}
}
我使用的图像是:
请帮助解决此问题问题。
谢谢
推荐答案
它没有'这样做很有效。它不会读取网格中的条形码,因为它假设它可以以某种与网格不兼容的方式剪切图像。您必须编写自己的方法将图像切割为可扫描区域。
It doesn't quite work this way. It will not read barcodes in a grid, as it makes an assumption that it can cut up the image in a certain way that won't be compatible with grids. You will have to write your own method to cut up the image into scannable regions.
数据矩阵解码器假设图像的中心位于内部条形码。这是您需要将图像预先切割成圆柱体周围的方块然后扫描的另一个原因。它应该工作得相当好。
It is also the case that the Data Matrix decoder assumes the center of the image is inside the barcode. This is another reason you need to pre-chop the image into squares around the cylinders and then scan. It ought to work fairly well then.
这篇关于使用zxing库读取多个条形码的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!