使用zxing库读取多个条形码的问题

我正在尝试使用zxing库(GenericMultipleBarcodeReader)读取2D数据矩阵条形码。 我在一张图片上有多个条形码。

问题是zing阅读器的效率非常低,它识别来自图像1.png的1个条形码,并且没有来自图像2.png的具有48个条形码的条形码。 有没有办法获得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 hints = new Hashtable(); 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()); } } } 

我使用的图像是:

1.png2.JPG

请帮助解决此问题。

谢谢

这种方式不太合适。 它不会读取网格中的条形码,因为它假设它可以以某种与网格不兼容的方式剪切图像。 您必须编写自己的方法将图像切割为可扫描区域。

情况也是数据矩阵解码器假设图像的中心在条形码内。 这是您需要将图像预先切割成圆柱体周围的方块然后扫描的另一个原因。 它应该工作得相当好。

另一种解决方案是考虑条形码引擎,该条形码引擎可以在一个文档上检测各种方向的多个条形码。 如果您在Windows上运行, ClearImage Barcode SDK具有Java API,并且无需预处理即可满足您的需求。 您可以使用在线条形码阅读器测试他们的引擎是否可以读取您的图像。

一些示例代码:

 public static void testDataMatrix () { try { String filename = "1.png "; CiServer objCi = new CiServer(); Ci = objCi.getICiServer(); ICiDataMatrix reader = Ci.CreateDataMatrix(); // read DataMatrix Barcode reader.getImage().Open(filename, 1); int n = reader.Find(0); // find all the barcodes in the doc for (i = 1; i <= n; i++) { ICiBarcode Bc = reader.getBarcodes().getItem(i); // getItem is 1-based System.out.println("Barcode " + i + " has Text: " + Bc.getText()); } } catch (Exception ex) {System.out.println(ex.getMessage());} } 

免责声明:我过去为Inlite做过一些工作。