简体   繁体   English

适用于 android 的 Google ML 套件条码扫描仪示例应用程序无法检测条码

[英]Google ML kit Barcode Scanner example app for android not able to detect barcodes

I'm trying to use the Google ML kit barcode detection feature.我正在尝试使用 Google ML 套件条形码检测功能。 For this, I have installed this example app provided by google.为此,我安装了谷歌提供的这个示例应用程序 I have also connected my app to one of my firebase projects.我还将我的应用程序连接到我的 firebase 项目之一。 When I open the app and go to LivePreviewActivity in that Barcode detection.当我打开应用程序并转到该条码检测中的 LivePreviewActivity 时。 The camera starts but no barcode is detected!.相机启动但未检测到条形码!。 As per the quick start guide I've also added根据快速入门指南,我还添加了

<meta-data
    android:name="com.google.firebase.ml.vision.DEPENDENCIES"
    android:value="barcode" />

in my manifest file.在我的清单文件中。 Also I have included this我也包括这个

FirebaseVisionBarcodeDetectorOptions options =
            new FirebaseVisionBarcodeDetectorOptions.Builder()
                    .setBarcodeFormats(
                            FirebaseVisionBarcode.FORMAT_CODE_128)
                    .build(); 

in BarcodeScanningProcessor.java file.在 BarcodeScanningProcessor.java 文件中。

The errors I'm getting is:我得到的错误是:

Barcode detection failed com.google.firebase.ml.common.FirebaseMLException: Waiting for the barcode detection model to be downloaded.条码检测失败 com.google.firebase.ml.common.FirebaseMLException:正在等待下载条码检测模型。 Please wait.请稍等。

E/BarcodeNativeHandle: Error Loading module E/BarcodeNativeHandle:加载模块时出错

java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.chimera.DynamiteModuleInitializer" java.lang.ClassNotFoundException:没有找到类“com.google.android.gms.chimera.DynamiteModuleInitializer”

I've installed this app on two phones Huawei Mate 8 and Samsung Galaxy S7 Edge.我已经在华为 Mate 8 和三星 Galaxy S7 Edge 两部手机上安装了这个应用程序。 The app is not able to detect barcodes from both the phones.该应用程序无法检测两部手机的条形码。

My aim is to detect/scan barcodes from live camera preview.我的目标是从实时相机预览中检测/扫描条形码。 Thanks.谢谢。

On the first part of the question "Waiting for the barcode detection model to be downloaded. Please wait."关于问题的第一部分“正在等待下载条码检测模型。请稍候。” :

This can happen if there is not enough storage on the device or the data connection is not there on the device.如果设备上没有足够的存储空间或设备上没有数据连接,就会发生这种情况。 Clear out the data of the Google Play Services and retrying should work:清除 Google Play 服务的数据并重试应该可以:

Settings->Apps->Google Play Services->Storage->Manage Space->Clear All Data

On the meta-data tag in the manifest part of the question:在问题清单部分的元数据标签上

That helps with the production use case ie when the end-user installs the app from the Play Store, the models are downloaded at install time with that meta-data tag.这有助于生产用例,即当最终用户从 Play 商店安装应用程序时,模型会在安装时使用该元数据标签下载。 However, during the development you still have to wait for the model to be downloaded once.但是,在开发过程中,您仍然需要等待模型下载一次。

On the last part of the question about Dynamite module loading error (I don't have enough reputation to add a comment yet, so adding it here):关于炸药模块加载错误的问题的最后一部分(我还没有足够的声誉来添加评论,所以在这里添加):

What Android version and the Google Play services version are you running?您运行的是哪个 Android 版本和 Google Play 服务版本?

Add this dependency.添加此依赖项。 It worked for me.它对我有用。

implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.0.2'

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

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