简体   繁体   English

Android的扫描仪(条形码)Api无法检测到条形码

[英]Scanner (Barcode) Api for Android does not detect the barcode

I would like to make an app as an barcode scanner. 我想做一个条形码扫描仪的应用程序。 I founded an barcode scanner api with the name android vision 我创建了一个名为android vision的条形码扫描仪api

I can start the app and hold my camera on a barcode. 我可以启动应用程序并将相机放在条形码上。 But the logs only says: 但是日志只说:

11-20 11:21:29.353 20243-20243/com.google.android.gms.samples.vision.barcodereader D/Barcode-reader: no barcode detected 11-20 11:21:29.353 20243-20243 / com.google.android.gms.samples.vision.barcodereader D /条形码阅读器:未检测到条形码

Can anyone tell me, why no barcode is detected? 谁能告诉我,为什么没有检测到条形码?

The barcodeDetector in google vision API is nor supported for all devices. 并非所有设备都支持google vision API中的barcodeDetector。 I faced this problem. 我遇到了这个问题。 It didn't work on my phone (ASUS) when I tried on 1+ mobile, it worked great. 当我在1+移动设备上尝试时,它在手机(ASUS)上无法正常工作,效果很好。 To know whether it is supported in you phone or not, just try this piece of code in "onCreate" of your main activity. 要知道您的电话是否支持该代码,只需在您的主要活动的“ onCreate”中尝试这段代码。

if(!barcodeDetector.isOperational()){
            Toast.makeText(getApplicationContext(), "Sorry, Couldn't setup the detector", Toast.LENGTH_LONG).show();
            this.finish();
        }

If the toast appear before the activity is launched in your mobile, it simply means the barcodeDetector is not supported for your device.I guess, this is fixed in higher versions of google play vision API. 如果在您的移动设备上启动该活动之前出现了吐司,则仅表示您的设备不支持barcodeDetector。我猜这已在更高版本的google play vision API中修复。

Try using google play vision API 9 and above. 尝试使用Google Play视觉API 9及更高版本。

There are some open issues with Barcode detection 条形码检测存在一些未解决的问题

  1. No barcode detected #8 This issue has a solution here https://stackoverflow.com/a/32029162/2691974 未检测到条形码#8此问题在此处有解决方法https://stackoverflow.com/a/32029162/2691974
  2. No Barcode detection #31 This is still a open issue in github 没有条形码检测#31这在github中仍然是一个未解决的问题
  3. There are other issues, some of them are due to focus problems, and some formats are not recognised properly. 还有其他问题,其中一些是由于焦点问题引起的,而某些格式则无法正确识别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM