Why is the new FaceDetector Play-Services not available on some devices?

Background

Google released a few months ago a new API for detecting faces in bitmaps:

It should be faster and better than the built-in FaceDetector class , and it has no limitations / compared to it (for example, the need for the input bitmap to have a configuration of 565, the width of the bitmap, which even has maximum edges for detection).

The code is pretty simple:

manifest:

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

Java:

FaceDetector faceDetector = new
       FaceDetector.Builder(getApplicationContext()).setTrackingEnabled(false)
.build();
if(!faceDetector.isOperational()){
   //show error
  return;
  }
Frame frame = new Frame.Builder().setBitmap(myBitmap).build();
SparseArray<Face> faces = faceDetector.detect(frame);

Problem

The API seems to be unavailable on some devices, returning "false" when calling "isOperational ()".

  • In Nexus 4 (Android 4.4.4) and Nexus 5 (Android 6.0.1) it does not work at all
  • On Nexus 5x (Android 6.0.1) and Galaxy S4 (Android 5.0) it works great
  • In LG G2 (Android 4.2.2), it worked only from the second sample launch.

What i found

I found some tips:

  • On Github ( here ), other people also discovered this problem.

  • ( "-", "PhotoViewerActivity.java" ) , , :

    if (!safeDetector.isOperational()) {
        // Note: The first time that an app using face API is installed on a device, GMS will
        // download a native library to the device in order to do detection.  Usually this
        // completes before the app is run for the first time.  But if that download has not yet
        // completed, then the above call will not detect any faces.
        //
        // isOperational() can be used to check if the required native library is currently
        // available.  The detector will automatically become operational once the library
        // download completes on device.
        Log.w(TAG, "Face detector dependencies are not yet available.");
    
        // Check for low storage.  If there is low storage, the native library will not be
        // downloaded, so detection will not become operational.
        IntentFilter lowstorageFilter = new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW);
        boolean hasLowStorage = registerReceiver(null, lowstorageFilter) != null;
    
        if (hasLowStorage) {
            Toast.makeText(this, R.string.low_storage_error, Toast.LENGTH_LONG).show();
            Log.w(TAG, getString(R.string.low_storage_error));
        }
    }
    

reset ( , , ), , , ( Nexus 5).

  • , API? ?

  • "isOperational" ?

  • Nexus? -, ?

  • / , ? , - ( ). try-catch (OutOfMemoryError) OOM?

+4
2

, , Google :

GMSCore (v9), . :

  • Mobile Vision - . , - . Mobile Vision , .
  • , Mobile Vision, FaceDetector.isOperational() BarcodeDetector.isOperational() - .
0

. , , :

  • Google Play
  • ​​ Google Play Services 8.7.xx apkmirror.
  • ( , )
  • , google play.
  • .....

.

PS: , Google Play Services. , .

0

All Articles