A FaceDetection
client for finding Faces in a supplied
image.
A FaceDetector
is created via
getClient(FaceDetectorOptions) or 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();
To perform face detection in an image, you first need to create an instance of
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);
Then the code below can detect faces in the supplied InputImage.
Task<List<Face>> task = faceDetector.process(image);
task.addOnSuccessListener(...).addOnFailureListener(...);
| abstract void |
close()
Closes the detector and releases its resources.
|
| abstract Task<List<Face>> |
Closes the detector and releases its resources.
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
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 UNAVAILABLE.
If there is no face gets detected, the returned Task will
contain an empty List.