FaceDetectorOptions.Builder

public static class FaceDetectorOptions.Builder extends Object

Builder class of FaceDetectorOptions.

Public Constructor Summary

Builder()
Creates a new builder to build FaceDetectorOptions.

Public Method Summary

FaceDetectorOptions
build()
Builds a face detector instance.
FaceDetectorOptions.Builder
enableTracking()
Enables face tracking, which will maintain a consistent ID for each face when processing consecutive frames.
FaceDetectorOptions.Builder
setClassificationMode(int classificationMode)
Indicates whether to run additional classifiers for characterizing attributes such as "smiling" and "eyes open" as defined in FaceDetectorOptions.ClassificationMode.
FaceDetectorOptions.Builder
setContourMode(int contourMode)
Sets whether to detect no contours or all contours as defined in FaceDetectorOptions.ContourMode.
FaceDetectorOptions.Builder
setExecutor(Executor executor)
Sets the custom Executor to use.
FaceDetectorOptions.Builder
setLandmarkMode(int landmarkMode)
Sets whether to detect no landmarks or all landmarks as defined in FaceDetectorOptions.LandmarkMode.
FaceDetectorOptions.Builder
setMinFaceSize(float minFaceSize)
Sets the smallest desired face size, expressed as a proportion of the width of the head to the image width.
FaceDetectorOptions.Builder
setPerformanceMode(int performanceMode)
Extended option for controlling additional accuracy / speed trade-offs in performing face detection as defined in FaceDetectorOptions.PerformanceMode.

Inherited Method Summary

Public Constructors

public Builder ()

Creates a new builder to build FaceDetectorOptions.

Public Methods

public FaceDetectorOptions build ()

Builds a face detector instance.

public FaceDetectorOptions.Builder enableTracking ()

Enables face tracking, which will maintain a consistent ID for each face when processing consecutive frames. Tracking should be disabled for handling a series of non-consecutive still images.

public FaceDetectorOptions.Builder setClassificationMode (int classificationMode)

Indicates whether to run additional classifiers for characterizing attributes such as "smiling" and "eyes open" as defined in FaceDetectorOptions.ClassificationMode.

Default: FaceDetectorOptions.CLASSIFICATION_MODE_NONE

Parameters
classificationMode the classification mode used by the detector. One of FaceDetectorOptions.CLASSIFICATION_MODE_NONE or FaceDetectorOptions.CLASSIFICATION_MODE_ALL

public FaceDetectorOptions.Builder setContourMode (int contourMode)

Sets whether to detect no contours or all contours as defined in FaceDetectorOptions.ContourMode. Processing time increases as the number of contours to search for increases, so detecting all contours will increase the overall detection time. Note that contours are detected for only the most prominent face in an image.

Default: FaceDetectorOptions.CONTOUR_MODE_NONE

Parameters
contourMode the contour mode used by the detector. One of FaceDetectorOptions.CONTOUR_MODE_NONE or FaceDetectorOptions.CONTOUR_MODE_ALL.

public FaceDetectorOptions.Builder setExecutor (Executor executor)

Sets the custom Executor to use. If no Executor is set, an internal background thread pool will be used.

Most clients should not need to call this method.

Parameters
executor the Executor to use
Returns
  • this object, for chaining method calls

public FaceDetectorOptions.Builder setLandmarkMode (int landmarkMode)

Sets whether to detect no landmarks or all landmarks as defined in FaceDetectorOptions.LandmarkMode. 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: FaceDetectorOptions.LANDMARK_MODE_NONE

Parameters
landmarkMode the landmark mode used by the detector. One of FaceDetectorOptions.LANDMARK_MODE_NONE or FaceDetectorOptions.LANDMARK_MODE_ALL.

public FaceDetectorOptions.Builder setMinFaceSize (float minFaceSize)

Sets the smallest desired face size, expressed as a proportion of the width of the head to the image width. For example, if a value of 0.1 is specified then the smallest face to search for is roughly 10% of the width of the image being searched.

Setting the min face size is a performance vs. accuracy trade-off: setting the face size smaller will enable the detector to find smaller faces but detection will take longer; setting the face size larger may exclude smaller faces but will run faster.

This is not a hard limit on face size; the detector may find faces slightly smaller than specified, so it can not be used to filter out face sizes.

Default minimum face size is 0.1.

Parameters
minFaceSize the head size to search for relative to the size of the image, in the range of 0.0 and 1.0. For example, a setting of 0.5 would indicate that detected faces is preferred to fill at least half of the image width. However, the detector may still find faces slightly smaller than specified, so it can not be used to filter out face sizes.

public FaceDetectorOptions.Builder setPerformanceMode (int performanceMode)

Extended option for controlling additional accuracy / speed trade-offs in performing face detection as defined in FaceDetectorOptions.PerformanceMode. 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: FaceDetectorOptions.PERFORMANCE_MODE_FAST

Parameters
performanceMode fast/accurate trade-off mode. One of FaceDetectorOptions.PERFORMANCE_MODE_FAST or FaceDetectorOptions.PERFORMANCE_MODE_ACCURATE.