This class is deprecated.
The standalone ML Kit SDK replaces this API. For more information, refer to the migration guide.
Detector for finding FirebaseVisionFace
s
in a supplied image.
A face detector is created via
getVisionFaceDetector(FirebaseVisionFaceDetectorOptions)
or
getVisionFaceDetector()
, if you wish to use the default options. For example, the
code below creates a face detector with default options.
FirebaseVisionFaceDetector faceDetector =
FirebaseVision.getInstance().getVisionFaceDetector();
To perform face detection in an image, you first need to create an instance of
FirebaseVisionImage
from a Bitmap
,
ByteBuffer
, etc. See
FirebaseVisionImage
documentation for more details. For example, the code below creates a FirebaseVisionImage
from a Bitmap
.
FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(bitmap);
Then
the code below can detect faces in the supplied FirebaseVisionImage
.
Task
<List<FirebaseVisionFace>> task = faceDetector.detectInImage(image);
task.addOnSuccessListener(...).addOnFailureListener(...);
Public Method Summary
void |
close()
Closes this
FirebaseVisionFaceDetector and releases its model resources.
|
Task<List<FirebaseVisionFace>> |
Inherited Method Summary
Public Methods
public void close ()
Closes this
FirebaseVisionFaceDetector
and releases its model resources.
Throws
IOException |
---|
public Task<List<FirebaseVisionFace>> detectInImage (FirebaseVisionImage image)
Detects human faces from the supplied image.
For best efficiency, create a
FirebaseVisionImage
object using one of the following ways:
fromMediaImage(Image, int)
with aYUV_420_888
formatted image fromandroid.hardware.camera2
.fromByteArray(byte[], FirebaseVisionImageMetadata)
with aNV21
formatted image fromCamera
(deprecated).fromByteBuffer(ByteBuffer, FirebaseVisionImageMetadata)
if you need to pre-process the image. E.g. allocate a directByteBuffer
and write processed pixels into theByteBuffer
.
FirebaseVisionImage
factory methods will work as well, but possibly slightly
slower.
Note that the width of the provided image cannot be less than 32 if
ALL_CONTOURS
is specified.
Returns
- A
Task
that asynchronously returns aList
of detectedFirebaseVisionFace
s.