Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
505 views
in Technique[技术] by (71.8m points)

android - FaceDetectorHandle﹕ Native face detector not yet available. Reverting to no-op detection

I'm trying to incorporate the Google Play Services 7.8 Face API in my app, but every time I try to detect faces it gives me the error:

FaceDetectorHandle﹕ Native face detector not yet available. Reverting to no-op detection

According to the bottom of the post Android-er Face Detection, this problem occurs on devices running Lollipop or later. Specifically, they said it works on a "RedMi 2, running Android 4.4.4 with Google Play services version 7.8.99 installed, but not on a Nexus 7 2012 (WITHOUT front camera) running Android 5.1.1, with the same?Google Play services version 7.8.99 installed." It also doesn't work on my OnePlus One running 5.0.2. Does anyone know the cause or fix? Will it eventually install the library and work?

Edit: Here are some logs. I just copied logs warning and higher around the time that the face detector was used, so it might not all be relevant.

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()
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The first time that face detection functionality is run on a device, it is necessary to download a face detection library to the device. The "Native face detector not yet available." message indicates that the library has not yet been downloaded.

It's recommended that the mobile vision dependencies are added to the AndroidManifest.xml. This will proactively request the library download when the app is installed. See this note in the docs:

Add the Vision Dependency to your Android Manifest

Adding the vision functionality dependency to your project's AndroidManifest.xml will indicate to the installer that it should download the dependency on app install time. Although this is not strictly required, it can make the user experience better when initially running your app. For example, adding the following to AndroidManifest.xml (in the application section) will indicate that both the barcode and face detection dependencies should be downloaded at app install time:

<meta-data android:name="com.google.android.gms.vision.DEPENDENCIES" android:value="barcode,face">

Valid vision dependency values are: barcode or face

However, even if this is supplied, in some cases the dependencies required to run the detectors may be downloaded on demand when your app is run for the first time rather than at install time. See isOperational() and detectorIsOperational() for more information on checking the dependency download status in your app.

As indicated above, your app can check for this with the isOperational() method:

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

The detector will try to download the libraries while your app is running, and will automatically become operational once the libraries have been obtained.

But in some cases the download might not succeed (e.g., if the device does not have sufficient free storage space, or if the device isn't connected to the network). The first thing to try would be freeing up more storage space.

Calling release()

The following warning from the log indicates a different issue:

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

Your app should call the release() method on the detector (or camera source) when it no longer needs it. This will free up resources. Although this isn't related to the download issue, it is good to do in general. For example, if the detector was created in an activity, it's good to release that resource in onDestroy():

protected void onDestroy() {
    super.onDestroy();
    mCameraSource.release();
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...