Android 用安卓读取条码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2240341/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:07:49  来源:igfitidea点击:

Reading barcodes with android

androidtrackingbarcodebarcode-scannerqr-code

提问by user233354

Hi I am developing an application for the android htc hero. I am looking into ways of using the inbuilt camer to read 2D barcodes and extract the string returned from the barcode. I have only recently begun working with the android sdk but I do have a programming background from working on projects with java. I am curious to know what the best way to read the 2D barcode would be. I have some sample applications that read the barcode but they are all .apk files and have no source or library that i can work with. to give you a better idea of what i am trying to accomplish this site allows the generation of 2d barcodes made up of the data you desire here

嗨,我正在为 android htc hero 开发一个应用程序。我正在研究使用内置摄像头读取二维条码并提取从条码返回的字符串的方法。我最近才开始使用 android sdk,但我确实有使用 java 进行项目的编程背景。我很想知道读取二维条码的最佳方式是什么。我有一些读取条码的示例应用程序,但它们都是 .apk 文件,没有可供我使用的源代码或库。为了让您更好地了解我要完成的工作,此站点允许生成由您在此处所需的数据组成的二维条码

Any replies would be greatly appreciated.

任何答复将不胜感激。

回答by Scharrels

Android programs can interact with eachother using intents. Intents are a little like remote procedure calls: you ask the other program for a certain action (e.g. scan a barcode) and the other program will perform this task for you. The result is returned when the task is complete.

Android 程序可以使用意图相互交互。Intent 有点像远程过程调用:您要求另一个程序执行某个操作(例如扫描条形码),另一个程序将为您执行此任务。任务完成后返回结果。

If the user has installed the ZXing Barcode Scanner, you can just use an intent to scan a barcode. The Barcode Scanner will then start, let the user scan the code and return the result to you.

如果用户已经安装了ZXing条码扫描器,你就可以使用intent来扫描条码了。Barcode Scanner 随后将启动,让用户扫描代码并将结果返回给您。

More information about this scanner can be found on the Google Code page of this project: http://code.google.com/p/zxing/wiki/ScanningViaIntent

关于这个扫描器的更多信息可以在这个项目的谷歌代码页面上找到:http: //code.google.com/p/zxing/wiki/ScanningViaIntent

回答by Mark B

I'd look at this open source Android project: http://code.google.com/p/zxing/

我会看看这个开源 Android 项目:http: //code.google.com/p/zxing/

回答by Taoufix

For fellow Google search travelers, there is a 2012 post on the android developers blog on how to use intents with the example of barcode scanning :

对于 Google 搜索旅行者,2012 年在 android 开发者博客上有一篇关于如何使用 Intent 和条形码扫描示例的帖子:

http://android-developers.blogspot.com/2012/02/share-with-intents.html

http://android-developers.blogspot.com/2012/02/share-with-intents.html

回答by ron

As far as I know for decoding barcodes (apart from the algorithm) you need to know the (relative) widths of white and black bars. For that, you would have to rotate the barcode to a horizontal position and then detect the widths.

据我所知,解码条形码(除了算法)你需要知道白条和黑条的(相对)宽度。为此,您必须将条形码旋转到水平位置,然后检测宽度。

(Ok, the ZXIng stuff advised by others outperforms this manual hacking)

(好吧,其他人推荐的ZXing东西优于这个手动黑客)