我知道有很多类似的问题( here 、 here 或 here )但即使我遵循了建议的说明,我仍然面临同样的问题。
即使我似乎正确配置了项目,Firebase ML Kit 似乎在下载设备上文本识别模型时出现问题,给我以下异常:com.google.firebase.ml.common.FirebaseMLException: Waiting for the text recognition model to be downloaded. Please wait.
该项目似乎根据 list 中的 DEPENDENCIES 元数据进行了配置,以在打开应用程序(或从 Play 商店下载)时下载依赖项:
<meta-data
android:name="com.google.firebase.ml.vision.DEPENDENCIES"
android:value="ocr" />
以及访问 Internet 和相机的权限:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
:app Gradle 实现了 ML Kit Vision:
implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
我也试过:
20.09.13 (120408-298964066)
. 我尝试使用该库的代码在这里(接口(interface)
ImageAnalysis.Analyzer
的实现):@SuppressLint("UnsafeExperimentalUsageError")
override fun analyze(imageProxy: ImageProxy) {
Log.d(LOG_TAG, "Trying to detect something")
val mediaImage = imageProxy.image
val imageRotation = degreesToFirebaseRotation(imageProxy.imageInfo.rotationDegrees)
if (mediaImage != null) {
val firebaseImage = FirebaseVisionImage.fromMediaImage(mediaImage, imageRotation)
val detector = FirebaseVision.getInstance().onDeviceTextRecognizer
val result = detector.processImage(firebaseImage)
.addOnSuccessListener { firebaseVisionText ->
// Task completed successfully
Log.d(LOG_TAG, "Text detected! ${firebaseVisionText.text}")
// Close img for next use
imageProxy.close()
}
.addOnFailureListener { e ->
// Task failed with an exception
Log.e(LOG_TAG, e.toString())
e.printStackTrace()
// Close img for next use
imageProxy.close()
}
}
}
是按照官方说明写的here .
这是完整的输出:
W/izadi.explorat: Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)
W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite.ocr not found.
I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite.ocr:0 and remote module com.google.android.gms.vision.dynamite.ocr:0
D/TextNativeHandle: Cannot load feature, fall back to load dynamite module.
W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.ocr not found.
I/DynamiteModule: Considering local module com.google.android.gms.vision.ocr:0 and remote module com.google.android.gms.vision.ocr:0
E/Vision: Error loading module com.google.android.gms.vision.ocr optional module true: com.google.android.gms.dynamite.DynamiteModule$LoadingException: No acceptable module found. Local version is 0 and remote version is 0.
E/OcrAnalyzer: com.google.firebase.ml.common.FirebaseMLException: Waiting for the text recognition model to be downloaded. Please wait.
W/System.err: com.google.firebase.ml.common.FirebaseMLException: Waiting for the text recognition model to be downloaded. Please wait.
W/System.err: at com.google.android.gms.internal.firebase_ml.zzsc.zzd(com.google.firebase:firebase-ml-vision@@24.0.1:21)
at com.google.android.gms.internal.firebase_ml.zzsc.zza(com.google.firebase:firebase-ml-vision@@24.0.1:39)
at com.google.android.gms.internal.firebase_ml.zzpj.zza(com.google.firebase:firebase-ml-common@@22.0.1:31)
at com.google.android.gms.internal.firebase_ml.zzpl.call(Unknown Source:8)
at com.google.android.gms.internal.firebase_ml.zzpf.zza(com.google.firebase:firebase-ml-common@@22.0.1:32)
at com.google.android.gms.internal.firebase_ml.zzpe.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at com.google.android.gms.internal.firebase_ml.zze.dispatchMessage(com.google.firebase:firebase-ml-common@@22.0.1:6)
at android.os.Looper.loop(Looper.java:227)
at android.os.HandlerThread.run(HandlerThread.java:67)
有任何想法吗?
有人对我缺少什么或如何解决有任何想法吗?它发生在我的设备(小米米 8 - Android 10)和虚拟设备(Nexus 5X - Android 10 + Play Store)中。
最佳答案
感谢您的反馈意见!
您拥有的 google play 服务版本 20.09.13 不在我们当前支持的可选模块下载列表中。理论上,我们应该支持 19.8.31 之后的所有当前 prod 版本(这将在新版本出来时改变)。
我将与 mu 同事再次核对,看看为什么你得到 20.08.13 并且它不在服务列表中。
同时,您可以尝试再次更新它,看看您是否可以获得新版本的 google play 服务?
谢谢!
关于android - ML Kit Vision 设备端文本识别未下载模型 : Waiting for the text recognition model to be downloaded. 请稍候,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60666655/