用zxing扫描多个1d条形码(code-128)

wmtdaxz3  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(240)

我已经设法用zxing扫描了一个tiff文件。这个文件里面有4个一维条形码,但是zxing显示了2个水平条形码。如何扫描垂直条形码?当前代码仅成功扫描水平条形码,但未能发现垂直条形码?
这是我的密码:

public static void main(String[] args) throws IOException, NotFoundException {
    InputStream barCodeInputStream = new FileInputStream("C:/Temp/test.tif");
    BufferedImage barCodeBufferedImage = ImageIO.read(barCodeInputStream);
    LuminanceSource source = new BufferedImageLuminanceSource(barCodeBufferedImage);
    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
    com.google.zxing.Reader reader = new MultiFormatReader();
    MultipleBarcodeReader bcReader = new GenericMultipleBarcodeReader(reader);

    Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
    hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);

    StringBuilder sb = new StringBuilder();
    for (Result result : bcReader.decodeMultiple(bitmap, hints)) {
        sb.append(result.getText()).append(" \n");
    }
    System.out.println(sb.toString());
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题