条形码扫描仪太慢,无法读取代码 [英] bar code scanner is too slow to read the code

查看:75
本文介绍了条形码扫描仪太慢,无法读取代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用codenameone码扫描程序库读取条形码。它使用第三方扫描仪,如果单独使用,则效果很好,并且可以快速读取条形码。但是使用codenameone应用程序时,同一台扫描仪太慢(大多数时候无法扫描)。我已经在三星设备和其他一些设备中对其进行了测试。结果不是很好。如何增强扫描器?

I have used codenameone codescanner library to read bar code. It uses third party scanner which if used separately works fine and is quick to read the bar code. But using codenameone app, the same scanner is too slow(most of the time unable to scan). I have tested it in samsung devices and few other devices. The outcome is not so good. How can I enhance the scanner?

代码:

 CodeScanner.getInstance().scanBarCode(new ScanResult() {

    public void scanCompleted(String contents, String formatName, byte[] rawBytes) {
        //barCode.setText("Bar: " + contents);
        cnt.addComponent(new Label(contents));
        cnt.revalidate();
    }

    public void scanCanceled() {
        System.out.println("cancelled");
    }

    public void scanError(int errorCode, String message) {
        System.out.println("err " + message);
    }
});   

还有另一件事,有时它会读取条形码,但给出的代码与下面的代码不同码。例如,我正在扫描移动设备的IMEI号,它有15-20个以上的数字,但是扫描仪会提供5-6位数字,而不是那些IMEI号。

One more thing, some time it reads the bar code but gives different code rather than those written below the code. for eg I was scanning IMEI no of mobile device, it has more than 15-20 numbers, but the scanner gives the 5-6 digit numbers other than those IMEI numbers. What happened here?

您可以在视频中看到问题所在...
https://youtu.be/xCtx0ZlFH0U

you can see the problem in the video... https://youtu.be/xCtx0ZlFH0U

推荐答案

Swift 5:

如果使用的是AVFoundation,则应使用以下元数据对象类型:

If you are using AVFoundation, you should use below metadata object types:

  metadataOutput.metadataObjectTypes = [
        AVMetadataObject.ObjectType.aztec,
        AVMetadataObject.ObjectType.code128,
        AVMetadataObject.ObjectType.code39,
        AVMetadataObject.ObjectType.code39Mod43,
        AVMetadataObject.ObjectType.code93,
        AVMetadataObject.ObjectType.dataMatrix,
        AVMetadataObject.ObjectType.ean13,
        AVMetadataObject.ObjectType.ean8,
        AVMetadataObject.ObjectType.face,
        AVMetadataObject.ObjectType.interleaved2of5,
        AVMetadataObject.ObjectType.itf14,
        AVMetadataObject.ObjectType.pdf417,
        AVMetadataObject.ObjectType.qr,
        AVMetadataObject.ObjectType.upce]

,您可以通知用户请勿使相机距离条形码太近。 (用于EAN条码)

and you can inform users that they should not bring the camera too close to the barcode. (for EAN barcodes)

这篇关于条形码扫描仪太慢,无法读取代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆