Android APIs
public final class

Face

extends Object
java.lang.Object
   ↳ android.hardware.camera2.params.Face

Class Overview

Describes a face detected in an image.

Summary

Constants
int ID_UNSUPPORTED The ID is -1 when the optional set of fields is unsupported.
int SCORE_MAX The maximum possible value for the confidence level.
int SCORE_MIN The minimum possible value for the confidence level.
Public Methods
Rect getBounds()
Bounds of the face.
int getId()
An unique id per face while the face is visible to the tracker.
Point getLeftEyePosition()
The coordinates of the center of the left eye.
Point getMouthPosition()
The coordinates of the center of the mouth.
Point getRightEyePosition()
The coordinates of the center of the right eye.
int getScore()
The confidence level for the detection of the face.
String toString()
Represent the Face as a string for debugging purposes.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ID_UNSUPPORTED

The ID is -1 when the optional set of fields is unsupported.

Constant Value: -1 (0xffffffff)

public static final int SCORE_MAX

The maximum possible value for the confidence level.

See Also
Constant Value: 100 (0x00000064)

public static final int SCORE_MIN

The minimum possible value for the confidence level.

See Also
Constant Value: 1 (0x00000001)

Public Methods

public Rect getBounds ()

Bounds of the face.

A rectangle relative to the sensor's SENSOR_INFO_ACTIVE_ARRAY_SIZE, with (0,0) representing the top-left corner of the active array rectangle.

There is no constraints on the the Rectangle value other than it is not-null.

public int getId ()

An unique id per face while the face is visible to the tracker.

If the face leaves the field-of-view and comes back, it will get a new id.

This is an optional field, may not be supported on all devices. If the id is .ID_UNSUPPORTED then the leftEyePosition, rightEyePosition, and mouthPositions are guaranteed to be null. Otherwise, each of leftEyePosition, rightEyePosition, and mouthPosition may be independently null or not-null. When devices report the value of key STATISTICS_FACE_DETECT_MODE as STATISTICS_FACE_DETECT_MODE_SIMPLE in CaptureResult, the face id of each face is expected to be .ID_UNSUPPORTED.

This value will either be .ID_UNSUPPORTED or otherwise greater than 0.

See Also

public Point getLeftEyePosition ()

The coordinates of the center of the left eye.

The coordinates are in the same space as the ones for getBounds(). This is an optional field, may not be supported on all devices. If not supported, the value will always be set to null. This value will always be null only if getId() returns .ID_UNSUPPORTED.

Returns
  • The left eye position, or null if unknown.

public Point getMouthPosition ()

The coordinates of the center of the mouth.

The coordinates are in the same space as the ones for getBounds(). This is an optional field, may not be supported on all devices. If not supported, the value will always be set to null. This value will always be null only if getId() returns .ID_UNSUPPORTED.

Returns
  • The mouth position, or null if unknown.

public Point getRightEyePosition ()

The coordinates of the center of the right eye.

The coordinates are in the same space as the ones for getBounds().This is an optional field, may not be supported on all devices. If not supported, the value will always be set to null. This value will always be null only if getId() returns .ID_UNSUPPORTED.

Returns
  • The right eye position, or null if unknown.

public int getScore ()

The confidence level for the detection of the face.

The range is .SCORE_MIN to .SCORE_MAX. .SCORE_MAX is the highest confidence.

Depending on the device, even very low-confidence faces may be listed, so applications should filter out faces with low confidence, depending on the use case. For a typical point-and-shoot camera application that wishes to display rectangles around detected faces, filtering out faces with confidence less than half of .SCORE_MAX is recommended.

public String toString ()

Represent the Face as a string for debugging purposes.

Returns
  • a printable representation of this object.