如何创建条码扫描器(Android)?

发布于 2024-12-14 02:50:24 字数 114 浏览 0 评论 0原文

有人可以告诉我创建条形码扫描仪应用程序(适用于 Android)是否困难? OpenCV 库是一个好的开始吗?在哪里可以找到清楚解释如何读取条形码的算法?我将感谢所有有关该主题的好材料!

提前致谢!

Can someone tell me if creating barcode scanner app (for Android) is difficult? Is OpenCV library good start? Where can I find algorithm which clearly explains how to read barcodes? I will appreciate all good materials about this topic!

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

定格我的天空 2024-12-21 02:50:24

ZXing 项目提供了一个独立的条形码读取器应用程序,通过 Android 的意图机制,可以由希望集成条形码扫描的其他应用程序调用。

最简单的方法是从应用程序中调用 ZXing SCAN Intent,如下所示:

public Button.OnClickListener mScan = new Button.OnClickListener() {
    public void onClick(View v) {
        Intent intent = new Intent("com.google.zxing.client.android.SCAN");
        intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
        startActivityForResult(intent, 0);
    }
};

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == 0) {
        if (resultCode == RESULT_OK) {
            String contents = intent.getStringExtra("SCAN_RESULT");
            String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
            // Handle successful scan
        } else if (resultCode == RESULT_CANCELED) {
            // Handle cancel
        }
    }
}

按下链接到 mScan 的按钮将直接启动到 ZXing 条码扫描仪屏幕(如果未安装 ZXing,则崩溃)。识别条形码后,您将在活动中的内容变量中收到结果。

为了避免崩溃并为您简化事情,ZXing 有 提供了一个实用程序类,您可以将其集成到您的应用程序中,通过将用户重定向到 Android 来使 ZXing 的安装更加顺利如果他们还没有安装的话,就去市场吧。

最后,如果您想将条形码扫描直接集成到您的应用程序中,而不依赖于安装单独的 ZXing 应用程序,那么它是一个开源项目,您可以这样做! :)

The ZXing project provides a standalone barcode reader application which — via Android's intent mechanism — can be called by other applications who wish to integrate barcode scanning.

The easiest way to do this is to call the ZXing SCAN Intent from your application, like this:

public Button.OnClickListener mScan = new Button.OnClickListener() {
    public void onClick(View v) {
        Intent intent = new Intent("com.google.zxing.client.android.SCAN");
        intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
        startActivityForResult(intent, 0);
    }
};

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == 0) {
        if (resultCode == RESULT_OK) {
            String contents = intent.getStringExtra("SCAN_RESULT");
            String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
            // Handle successful scan
        } else if (resultCode == RESULT_CANCELED) {
            // Handle cancel
        }
    }
}

Pressing the button linked to mScan would launch directly into the ZXing barcode scanner screen (or crash if ZXing isn't installed). Once a barcode has been recognised, you'll receive the result in your Activity, here in the contents variable.

To avoid the crashing and simplify things for you, ZXing have provided a utility class which you could integrate into your application to make the installation of ZXing smoother, by redirecting the user to the Android Market if they don't have it installed already.

Finally, if you want to integrate barcode scanning directly into your application without relying on having the separate ZXing application installed, well then it's an open source project and you can do so! :)

|煩躁 2024-12-21 02:50:24

您可以使用现有的 Android 版斑马线条码扫描仪,网址为:http://code.google.com /p/zxing/。通常的想法是,您可以通过意图调用它,如下例所示: http:// /code.google.com/p/zxing/wiki/ScanningViaIntent

You can use the existing Zebra Crossing barcode scanner for Android, available at: http://code.google.com/p/zxing/. Typically the idea is that you would invoke it via intents, like in the example here: http://code.google.com/p/zxing/wiki/ScanningViaIntent.

庆幸我还是我 2024-12-21 02:50:24

Zebra Crossing 是记录最好的 java 1D 或 2D 条形码解码器或编码器。很多人使用它,它已经成为 Android 事实上的标准。这里也有关于它的健康讨论

RedLaser 有一个API,但是如果你使用它,你需要付费在生产中。当我尝试时,我并没有发现它比斑马线有什么惊人的改进。当然不是价格

jjil 有条形码,但该项目只有 3 位提交者,而且我自己从未使用过它,所以我不知道该告诉你什么。其来源肯定是可读。

一旦您开始阅读,您就会找到读者由于图像模糊、噪声、失真、奇怪的角度等,实现起来很棘手。因此,如果您想要可靠的东西,您可能想要使用社区维护的库。

Zebra Crossing is the best documented java 1D or 2D barcode decoder or encoder around. Lots of people use it, and it's become the de facto standard for android. There's a healthy buzz about it on here too.

RedLaser has an api, but you'll have to pay if you use it in production. When I tried it out, I didn't find it to be a spectacular improvement over Zebra Crossing. Certainly not for the price.

jjil does barcodes but there are only 3 committers on the project, and I've never used it myself so I don't know what to tell you about it. Its source is certainly readable.

Once you start reading, you'll find readers are tricky things to implement due to blurry images, noise, distortion, weird angles, and so forth. So if you want something reliable, you probably want to go with a community-maintained library.

简美 2024-12-21 02:50:24

您可以使用 zbar 库。从以下位置下载:
http://sourceforge.net/projects/zbar/files/AndroidSDK/

我认为这比zxing更快更准确。

You can use zbar library. Download it from:
http://sourceforge.net/projects/zbar/files/AndroidSDK/

I think this is more fast and accurate than zxing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文