如何使用 Android API 将条形码转换为整数
我是 Android 编程新手,想创建一个需要能够扫描条形码才能按照我想要的方式运行的应用程序。我发现了一个名为 zxing 的开源库,但经过一番阅读后,我发现它需要您的设备上安装 zxing 应用程序才能使用它。我不希望该应用程序成为一项要求,原因有几个,但主要原因是我计划出售我的应用程序,并认为付费应用程序本身应该具有完整的功能。
其他论坛中的一些人提到,实现 zxing 库中包含的所有功能并不是一项简单的任务,但我不需要它拥有的所有功能。我所需要的只是能够获取 GTIN-12 或 EAN-13 条形码(我认为这些是书籍、CD 和其他家居用品上常用的条形码类型)并将其转换为任意(或非任意)整数。这些数字不必与产品或条形码实际代表的内容有任何关系。我对使用它们来查找产品或做任何类似于其他各种应用程序已经做得足够好的事情不感兴趣。
我的问题是我不明白如何处理相机拍摄的图像,以便我能够做到这一点。例如,我如何裁剪图像的其余部分(除了条形码本身之外的所有内容)并测量其中包含的线条和空格的宽度?
I am new to programming on the Android and would like to create an app which requires the ability to scan barcodes to function the way I want it to. I found an open source library called zxing, but after some reading around I found that it requires you to have the zxing app on your device in order to use it. I do not want that app to be a requirement for a couple of reasons, but the main one is that I plan on selling my app and feel that a paid app should be fully functional by itself.
A few people in other forums have mentioned that it would not be a trivial task to implement all the features contained within the zxing library, but I do not need all the functionality it has. All I need is the ability to take GTIN-12 or EAN-13 barcodes (I think those are the types of barcodes commonly used on books, cd's and other household items) and convert them to an arbitrary(or not arbitrary) integer. The numbers don't have to be in any way related to the product or what the barcode is actually supposed to represent. I am not interested in using them to look up products or do anything similar to what various other applications can already do well enough.
My problem is that I don't understand how to process an image taken by the camera in such away that would allow me to do this. For example, how would I crop out the rest of the image (everything besides the barcode itself) and measure the widths of the lines and spaces contained within?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试 http://developer.scanlife.com/products/scanlife-sdk
您将需要不过,要注册,我不知道该 API 的自由度是多少,但是从头开始分析条形码将是一项不小的壮举,所以我建议您使用可用的选项之一(就像您提到zxing,就不会了第一个需要安装条形码扫描仪的应用程序)
Try http://developer.scanlife.com/products/scanlife-sdk
You will need to register, though, and I don't know what is the level of freedom with that API, but analyzing the barcode from scratch will be no small feat to do, so I suggest you to use one of the available options (like as you mentioned zxing, it would not be the first app that requires a barcode scanner installed)