【问题标题】:Zxing - UPC +5 Supplement Barcode DetectionZxing-UPC+5补充条码检测
【发布时间】:2014-01-09 19:51:06
【问题描述】:

我一直在尝试使用 Zxing 2.3.0 在 Java 中读取带有 +5 补充的 UPC 条形码图像,但是我无法读取条形码的补充部分。该代码仅成功读取了第一部分。在搜索了多个网站后,除了我目前的方法之外,我找不到任何关于如何阅读补充的进一步迹象。任何帮助将不胜感激。

public static void main(String[] args) {
    decodeUPC5();
}

public static void decodeUPC5(){

    InputStream barCodeInputStream = null;
    try {
        barCodeInputStream = new FileInputStream("C:/Users/apoclyps/git/zxing-barcoder/Zxing-Test/img/upc5.png");
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

    BufferedImage barCodeBufferedImage = null;
    try {
        barCodeBufferedImage = ImageIO.read(barCodeInputStream);
    } catch (IOException e) {
        e.printStackTrace();
    }

    LuminanceSource source = new BufferedImageLuminanceSource(barCodeBufferedImage);
    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

    // Attempting to read UPC + 5 Supplement
    GenericMultipleBarcodeReader  multiReader = new GenericMultipleBarcodeReader(new MultiFormatReader());
    try {
        multiReader.decodeMultiple(bitmap);
    } catch (NotFoundException e1) {
        e1.printStackTrace();
    }
    Result[] result = null;
    try {
        result = multiReader.decodeMultiple(bitmap);
    } catch (NotFoundException e) {
        e.printStackTrace();
    }

    System.out.println("Results length "+result.length);
    for(Result r : result ){
        System.out.println("Barcode text is " + r.toString());
    }
}

Barcode image!

输出 结果长度 1 条码文字为 9780735200449

【问题讨论】:

    标签: java barcode zxing


    【解决方案1】:

    请记住,条形码的内容是9780735200449,而不是9780735200449 51299。它总是(正确地)返回9780735200449 作为条形码的内容。

    +5 扩展名返回为 ResultMetadata,在键 ResultMetadatatype.UPC_EAN_EXTENSION 下。

    请注意,即使它没有看到 +5 扩展名,它仍然会返回 UPC 条形码,很明显。因此,您可能会看到它在此图像上没有 +5 扩展名的情况下返回。但是它适用于我的应用程序,因此可以想象它很容易检测到 +5。 (如果您使用应用程序扫描,请查看左侧的“元数据 $12.99”)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多