FirebaseVisionFaceDetector

public class FirebaseVisionFaceDetector extends Object
implements Closeable Closeable

This class is deprecated.
The standalone ML Kit SDK replaces this API. For more information, refer to the migration guide.

Detector for finding FirebaseVisionFaces 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>>
detectInImage(FirebaseVisionImage image)
Detects human faces from the supplied image.

Inherited Method Summary

Object
clone()
boolean
equals(Object arg0)
void
finalize()
final Class<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()
abstract void
close()
abstract void
close()

Public Methods

public void close ()

Closes this FirebaseVisionFaceDetector and releases its model resources.

Throws

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:

All other 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

Firebase gives you the tools and infrastructure you need to build better mobile and web apps, improve app quality, and grow your business.

Updated Aug 14, 2020

ML Kit for Firebase provided ready-to-use ML solutions for app developers. New apps should use the standalone ML Kit library for on-device ML and Firebase ML for cloud-based ML.

Updated Feb 3, 2025

Learn how to accelerate app development, run your app with confidence, and deliver a high quality user experience at Firebase Summit 2022.

Updated Jun 13, 2024