3

我正在尝试将 Google Play Services 7.8 Face API 合并到我的应用程序中,但每次我尝试检测人脸时都会出现错误:

FaceDetectorHandle﹕本机人脸检测器尚不可用。恢复到无操作检测

根据Android-er Face Detection帖子的底部,这个问题发生在运行 Lollipop 或更高版本的设备上。具体来说,他们说它适用于“RedMi 2,运行 Android 4.4.4 并安装了 Google Play 服务版本 7.8.99,但不适用于运行 Android 5.1.1 的 Nexus 7 2012(不带前置摄像头),具有相同的 Google Play服务版本 7.8.99 已安装。” 它也不适用于我运行 5.0.2 的 OnePlus One。有谁知道原因或解决方法?它最终会安装库并工作吗?

编辑:这里有一些日志。我只是在使用面部检测器时复制了日志警告和更高版本,因此可能并非全部相关。

08-19 17:29:17.828 W/ResourcesManager(25536): Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
08-19 17:29:17.828 W/ResourcesManager(25536): Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
08-19 17:29:17.908 W/FaceDetectorHandle(25536): Native face detector not yet available.  Reverting to no-op detection.
08-19 17:29:18.060 W/ResourcesManager(25536): Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
08-19 17:29:18.060 W/ResourcesManager(25536): Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
08-19 17:29:20.267 W/LatinIME( 1645): Deprecated private IME option specified: nm,com.google.android.inputmethod.latin.noGestureFloatingPreview
08-19 17:29:20.267 W/LatinIME( 1645): Use com.google.android.inputmethod.latin.noMicrophoneKey instead
08-19 17:29:20.294 E/EntSec  (  923): [QSB   ] [QSB_CLIENT ] No connection with the NQS
08-19 17:29:20.306 E/EntSec  (  923): [QSB   ] [QSB_CLIENT ] No connection with the NQS
08-19 17:29:20.317 E/EntSec  (  923): [QSB   ] [QSB_CLIENT ] No connection with the NQS
08-19 17:29:20.532 E/EntSec  (  923): [QSB   ] [QSB_CLIENT ] No connection with the NQS
08-19 17:29:20.655 W/OpenGLRenderer( 1814): Incorrectly called buildLayer on View: CoreSuggestionView, destroying layer...
08-19 17:29:20.655 W/OpenGLRenderer( 1814): Incorrectly called buildLayer on View: CoreSuggestionView, destroying layer...
08-19 17:29:20.655 W/OpenGLRenderer( 1814): Incorrectly called buildLayer on View: CoreSuggestionView, destroying layer...
08-19 17:29:20.655 W/OpenGLRenderer( 1814): Incorrectly called buildLayer on View: NowProgressBar, destroying layer...
08-19 17:29:20.655 W/OpenGLRenderer( 1814): Incorrectly called buildLayer on View: CrossfadingWebImageView, destroying layer...
08-19 17:29:20.655 W/OpenGLRenderer( 1814): Incorrectly called buildLayer on View: ew, destroying layer...
08-19 17:29:20.912 W/LatinIME( 1645): Deprecated private IME option specified: nm,com.google.android.inputmethod.latin.noGestureFloatingPreview
08-19 17:29:20.912 W/LatinIME( 1645): Use com.google.android.inputmethod.latin.noMicrophoneKey instead
08-19 17:29:20.924 E/EntSec  (  923): [QSB   ] [QSB_CLIENT ] No connection with the NQS
08-19 17:29:20.934 W/Search.SearchUrlHelper( 1969): URL param or header with a key: "oq" has an empty value.
08-19 17:29:20.941 E/EntSec  (  923): [QSB   ] [QSB_CLIENT ] No connection with the NQS
08-19 17:29:20.956 E/EntSec  (  923): [QSB   ] [QSB_CLIENT ] No connection with the NQS
08-19 17:29:21.038 W/IInputConnectionWrapper( 1814): performPrivateCommand on inactive InputConnection
08-19 17:29:21.085 W/BindingManager( 1969): Cannot call determinedVisibility() - never saw a connection for the pid: 1969
08-19 17:29:21.764 W/VelvetPresenter( 1969): Still observing while not the active client
08-19 17:29:21.765 W/VelvetPresenter( 1969): Still observing while not the active client
08-19 17:29:22.067 W/BindingManager( 1969): Cannot call determinedVisibility() - never saw a connection for the pid: 1969
08-19 17:29:22.250 W/WebViewRenderState( 1969): resultsPageEnd: not current commit, new=27, committed=0
08-19 17:29:22.344 W/SurfaceFlinger(  243): couldn't log to binary event log: overflow.
08-19 17:29:22.371 W/OpenGLRenderer( 1814): Incorrectly called buildLayer on View: ew, destroying layer...
08-19 17:29:22.462 E/WebViewWorkerImpl( 1969): onShowedSrp: No SearchResult found being shown in WebView.
08-19 17:29:26.635 W/FaceDetector(25536): FaceDetector was not released with FaceDetector.release()
4

2 回答 2

3

由于该服务存在问题,Mobile Vision 所需的服务现已禁用。这将阻止尚未使用面部或条形码检测的用户使用这些功能。在解决此问题之前,我们不建议您向您的应用添加新的 Mobile Vision 功能。

公告

有一项服务可以下载 Mobile Vision 运行所需的文件,但由于在开发后期发现了一个严重的错误,现在该服务已被禁用。这将阻止尚未使用人脸或条形码检测的用户使用人脸或条形码扫描。我们向 Google Play 服务开发者提供以下建议:

在解决此问题之前,请勿添加新的 Mobile Vision 功能。对于已经使用 Mobile Vision 功能的应用,请调用 FaceDetector.isOperational() 或 BarcodeDetector.isOperational() 以检查检测器是否准备就绪并相应地降低功能操作。我们正在努力尽快解决问题。我们预计需要数周时间才能对其进行彻底测试。

来源:https ://developers.google.com/vision/announcement

于 2016-06-01T05:34:45.943 回答
3

第一次在设备上运行人脸检测功能时,需要将人脸检测库下载到设备上。“本机面部检测器尚不可用。” 消息表明该库尚未下载。

建议将移动视觉依赖项添加到 AndroidManifest.xml。这将在安装应用程序时主动请求库下载。请参阅文档中的此注释:

将 Vision 依赖项添加到您的 Android 清单中

将视觉功能依赖项添加到项目的 AndroidManifest.xml 将向安装程序指示它应该下载应用程序安装时间的依赖项。虽然这不是严格要求,但它可以在最初运行您的应用程序时使用户体验更好。例如,将以下内容添加到 AndroidManifest.xml(在应用程序部分)将表明条形码和面部检测依赖项都应在应用安装时下载:

<元数据 android:name="com.google.android.gms.vision.DEPENDENCIES" android:value="barcode,face">

有效的视觉依赖值是:条形码或面部

但是,即使提供了它,在某些情况下,运行检测器所需的依赖项可能会在您的应用程序首次运行时按需下载,而不是在安装时。有关检查应用程序中的依赖项下载状态的更多信息,请参阅 isOperational() 和检测器IsOperational()。

如上所述,您的应用程序可以使用 isOperational() 方法检查这一点:

https://developers.google.com/android/reference/com/google/android/gms/vision/face/FaceDetector.html#isOperational()

检测器将在您的应用程序运行时尝试下载库,并在获取库后自动运行。

但在某些情况下,下载可能不会成功(例如,如果设备没有足够的可用存储空间,或者如果设备未连接到网络)。首先要尝试的是释放更多的存储空间。

调用释放()

日志中的以下警告表明存在不同的问题:

W/FaceDetector(25536): FaceDetector was not released with FaceDetector.release()

当不再需要检测器(或摄像头源)时,您的应用应调用 release() 方法。这将释放资源。虽然这与下载问题无关,但总的来说还是不错的。例如,如果检测器是在活动中创建的,最好在 onDestroy() 中释放该资源:

protected void onDestroy() {
    super.onDestroy();
    mCameraSource.release();
}
于 2015-08-20T15:33:41.173 回答