java.lang.Object | |
↳ | com.google.android.gms.vision.face.FaceDetector.Builder |
Builder for creating face detector instances.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a face detector builder with the supplied context.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Builds a face detector instance.
| |||||||||||
Indicates whether to run additional classifiers for characterizing attributes such as
“smiling” and “eyes open”.
| |||||||||||
Sets whether to detect no landmarks or all landmarks.
| |||||||||||
Sets the smallest desired face size, expressed as a proportion of the width of the head to
the image width.
| |||||||||||
Extended option for controlling additional accuracy / speed trade-offs in performing face
detection.
| |||||||||||
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).
| |||||||||||
Enables or disables face tracking, which will maintain a consistent ID for each face when
processing consecutive frames.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Creates a face detector builder with the supplied context.
Parameters | |
---|---|
context |
Context
|
Builds a face detector instance.
Note that this method may cause blocking disk reads and should not be called on an
application's main thread. To avoid blocking the main thread, consider moving Detector
construction to a background thread using AsyncTask
. Enable
StrictMode
to automatically detect blocking operations on the main
thread.
Returns | |
---|---|
FaceDetector |
Indicates whether to run additional classifiers for characterizing attributes such as
“smiling” and “eyes open”. Default: NO_CLASSIFICATIONS
Parameters | |
---|---|
classificationType |
int :
the subset of classifiers to use. One of NO_CLASSIFICATIONS or ALL_CLASSIFICATIONS . |
Returns | |
---|---|
FaceDetector.Builder |
Throws | |
---|---|
IllegalArgumentException |
if classificationType is invalid. |
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 |
int :
the type of landmark detector to use. One of NO_LANDMARKS or ALL_LANDMARKS . |
Returns | |
---|---|
FaceDetector.Builder |
Throws | |
---|---|
IllegalArgumentException |
if an invalid landmark detector type is provided |
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 will 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.
By default, this value is inferred by the prominentFaceOnly
setting. If unspecified, the inferred face size is 0.1 (prominentFaceOnly
== false) or 0.35 (prominentFaceOnly == true).
Parameters | |
---|---|
proportionalMinFaceSize |
float :
the smallest 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 need to fill at least half of the image width. |
Returns | |
---|---|
FaceDetector.Builder |
Throws | |
---|---|
IllegalArgumentException |
if an invalid proportion is provided |
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 |
int :
fast/accurate trade-off mode. One of FAST_MODE or ACCURATE_MODE . |
Returns | |
---|---|
FaceDetector.Builder |
Throws | |
---|---|
IllegalArgumentException |
if mode is invalid. |
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.
Parameters | |
---|---|
prominentFaceOnly |
boolean
|
Returns | |
---|---|
FaceDetector.Builder |
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.
Parameters | |
---|---|
trackingEnabled |
boolean
|
Returns | |
---|---|
FaceDetector.Builder |