Android APIs
public static class

FaceDetector.Builder

extends Object
java.lang.Object
   ↳ com.google.android.gms.vision.face.FaceDetector.Builder

Class Overview

Builder for creating face detector instances.

Summary

Public Constructors
FaceDetector.Builder(Context context)
Creates a face detector builder with the supplied context.
Public Methods
FaceDetector build()
Builds a face detector instance.
FaceDetector.Builder setClassificationType(int classificationType)
Indicates whether to run additional classifiers for characterizing attributes such as “smiling” and “eyes open”.
FaceDetector.Builder setLandmarkType(int landmarkType)
Sets whether to detect no landmarks or all landmarks.
FaceDetector.Builder setMode(int mode)
Extended option for controlling additional accuracy / speed trade-offs in performing face detection.
FaceDetector.Builder setProminentFaceOnly(boolean prominentFaceOnly)
Indicates whether to detect all faces, or to only detect the most prominent face (i.e., a large face that is most central within the frame).
FaceDetector.Builder setTrackingEnabled(boolean trackingEnabled)
Enables or disables face tracking, which will maintain a consistent ID for each face when processing consecutive frames.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public FaceDetector.Builder (Context context)

Creates a face detector builder with the supplied context.

Public Methods

public FaceDetector build ()

Builds a face detector instance.

public FaceDetector.Builder setClassificationType (int classificationType)

Indicates whether to run additional classifiers for characterizing attributes such as “smiling” and “eyes open”. Default: NO_CLASSIFICATIONS

Parameters
classificationType the subset of classifiers to use. One of NO_CLASSIFICATIONS or ALL_CLASSIFICATIONS.
Throws
IllegalArgumentException if classificationType is invalid.

public FaceDetector.Builder setLandmarkType (int landmarkType)

Sets whether to detect no landmarks or all landmarks. Processing time increases as the number of landmarks to search for increases, so detecting all landmarks will increase the overall detection time. Detecting landmarks can improve pose estimation. Default: NO_LANDMARKS

Parameters
landmarkType the type of landmark detector to use. One of NO_LANDMARKS or ALL_LANDMARKS.
Throws
IllegalArgumentException if an invalid landmark detector type is provided

public FaceDetector.Builder setMode (int mode)

Extended option for controlling additional accuracy / speed trade-offs in performing face detection. In general, choosing the more accurate mode will generally result in longer runtime, whereas choosing the faster mode will generally result in detecting fewer faces. Default: FAST_MODE

Parameters
mode fast/accurate trade-off mode. One of FAST_MODE or ACCURATE_MODE.
Throws
IllegalArgumentException if mode is invalid.

public FaceDetector.Builder setProminentFaceOnly (boolean prominentFaceOnly)

Indicates whether to detect all faces, or to only detect the most prominent face (i.e., a large face that is most central within the frame). Default: false

By default, there is no limit in the number of faces detected. Setting this value to true can increase the speed of the detector since the detector does not need to search exhaustively for all faces.

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.