Friday, August 14, 2015

FaceDetector error: Cannot resolve method setTrackingEnabled(boolean)

As mentioned in last post "Face Detection with Google Play services, Mobile Vision API (with demo APK)", calling setTrackingEnabled(false) method of FaceDetector object return error of "Cannot resolve method setTrackingEnabled(boolean)".

After checking reference of com.google.android.gms.vision.face.FaceDetector, setTrackingEnabled(boolean) is not a method of FaceDetector class. It's a method of com.google.android.gms.vision.face.FaceDetector.Builder class.


public FaceDetector.Builder setTrackingEnabled (boolean trackingEnabled)
Enables or disables face tracking, which will maintain a consistent ID for each face when processing consecutive frames. Default: true


If your code uses a MultiProcessor or FocusingProcessor instance, tracking must be enabled. Having tracking enabled is also recommended for handling live video.

Tracking should be disabled for handling a series of non-consecutive still images.


To fix the error, modify the code
        FaceDetector faceDetector = new FaceDetector.Builder(getApplicationContext()).build();
        faceDetector.setTrackingEnabled(false);

to:
        FaceDetector faceDetector =
                new FaceDetector.Builder(getApplicationContext())
                .setTrackingEnabled(false)
                .build();


No comments:

Post a Comment