public class

FaceDetector

extends Object
java.lang.Object
   ↳ android.media.FaceDetector

Class Overview

Identifies the faces of people in a Bitmap graphic object.

Summary

Nested Classes
class FaceDetector.Face A Face contains all the information identifying the location of a face in a bitmap. 
Public Constructors
FaceDetector(int width, int height, int maxFaces)
Creates a FaceDetector, configured with the size of the images to be analysed and the maximum number of faces that can be detected.
Public Methods
int findFaces(Bitmap bitmap, Face[] faces)
Finds all the faces found in a given Bitmap.
Protected Methods
void finalize()
Is called before the object's memory is being reclaimed by the VM.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public FaceDetector (int width, int height, int maxFaces)

Since: API Level 1

Creates a FaceDetector, configured with the size of the images to be analysed and the maximum number of faces that can be detected. These parameters cannot be changed once the object is constructed.

Parameters
width the width of the image
height the height of the image
maxFaces the maximum number of faces to identify

Public Methods

public int findFaces (Bitmap bitmap, Face[] faces)

Since: API Level 1

Finds all the faces found in a given Bitmap. The supplied array is populated with FaceDetector.Faces for each face found. The bitmap must be in 565 format (for now).

Parameters
bitmap the Bitmap graphic to be analyzed
faces an array in which to place all found FaceDetector.Faces. The array must be sized equal to the maxFaces value set at initialization
Returns
  • the number of faces found
Throws
IllegalArgumentException if the Bitmap dimensions don't match the dimensions defined at initialization or the given array is not sized equal to the maxFaces value defined at initialization

Protected Methods

protected void finalize ()

Since: API Level 1

Is called before the object's memory is being reclaimed by the VM. This can only happen once the VM has detected, during a run of the garbage collector, that the object is no longer reachable by any thread of the running application.

The method can be used to free system resources or perform other cleanup before the object is garbage collected. The default implementation of the method is empty, which is also expected by the VM, but subclasses can override finalize() as required. Uncaught exceptions which are thrown during the execution of this method cause it to terminate immediately but are otherwise ignored.

Note that the VM does guarantee that finalize() is called at most once for any object, but it doesn't guarantee when (if at all) finalize() will be called. For example, object B's finalize() can delay the execution of object A's finalize() method and therefore it can delay the reclamation of A's memory. To be safe, use a ReferenceQueue, because it provides more control over the way the VM deals with references during garbage collection.

Throws
Throwable