AI-generated Key Takeaways
-
FaceDetector
is a client for finding faces within images, created usingFaceDetection.getClient()
with optional configurations. -
It uses
InputImage
, created from sources like Bitmaps, for processing and detecting faces. -
The
process()
method asynchronously detects faces in the input image, returning a list ofFace
objects or an empty list if none are found. -
FaceDetector
can be closed using theclose()
method to release resources. -
For contour detection with
FaceDetectorOptions.CONTOUR_MODE_ALL
, the input image width should be at least 32 pixels.
A FaceDetection
client for finding Face
s in a supplied
image.
A FaceDetector
is created via
FaceDetection.getClient(FaceDetectorOptions)
or FaceDetection.getClient()
,
if you wish to use the default options. For example, the code below creates a face detector
client with default options.
FaceDetector faceDetector = FaceDetection.getClient();
InputImage
from a Bitmap
,
ByteBuffer
,
Image
etc. See InputImage
documentation for more details. For example, the code below creates an InputImage
from a Bitmap
.
InputImage image = InputImage.fromBitmap(bitmap, rotationDegrees);
InputImage
.
Task<List<Face>> task = faceDetector.process(image);
task.addOnSuccessListener(...).addOnFailureListener(...);
Public Method Summary
abstract void |
close()
Closes the detector and releases its resources.
|
abstract Task<List<Face>> | |
abstract Task<List<Face>> |
Inherited Method Summary
Public Methods
public abstract void close ()
Closes the detector and releases its resources.
public abstract Task<List<Face>> process (MlImage image)
Detects human faces from the supplied image.
This is an experimental API in beta version.
Create an MlImage
object using one of MlImage
's
builder methods. See MlImage
documentation for more details.
Note that the width of the provided image cannot be less than 32 if
FaceDetectorOptions.CONTOUR_MODE_ALL
is specified.
If the face detection model has not been downloaded yet when you are depending on
com.google.android.gms:play-services-mlkit-face-detection, the returned Task
will
contain an MlKitException
with error code MlKitException.UNAVAILABLE
.
If there is no face gets detected, the returned Task
will
contain an empty List
.
public abstract Task<List<Face>> process (InputImage image)
Detects human faces from the supplied image.
Create an InputImage
object using one of InputImage
's
factory methods. See InputImage
documentation for more details.
Note that the width of the provided image cannot be less than 32 if
FaceDetectorOptions.CONTOUR_MODE_ALL
is specified.
If the face detection model has not been downloaded yet when you are depending on
com.google.android.gms:play-services-mlkit-face-detection, the returned Task
will
contain an MlKitException
with error code MlKitException.UNAVAILABLE
.
If there is no face gets detected, the returned Task
will
contain an empty List
.