Issue to read multiple barcodes using zxing library

后端 未结 2 797
旧时难觅i
旧时难觅i 2020-12-19 22:39

I am trying to read 2D Data matrix barcode using zxing library(GenericMultipleBarcodeReader). I have multiple barcodes on a single image.

The problem

相关标签:
2条回答
  • 2020-12-19 23:11

    An alternative solution is to consider a barcode engine that can detect multiple barcodes in various orientations on one document. If you're running on Windows, the ClearImage Barcode SDK has a Java API and should be able to handle your needs without pre-processing. You can test if their engine can read your image using their Online Barcode Reader.

    Some sample code:

    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());}
     }
    

    Disclaimer: I've done some work for Inlite in the past.

    0 讨论(0)
  • 2020-12-19 23:23

    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.

    0 讨论(0)
提交回复
热议问题