Added in API level 21

Face


class Face
kotlin.Any
   ↳ android.hardware.camera2.params.Face

Describes a face detected in an image.

Summary

Nested classes

Builds a Face object.

Constants
static Int

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

static Int

The maximum possible value for the confidence level.

static Int

The minimum possible value for the confidence level.

Public methods
Rect!

Bounds of the face.

Int

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

Point!

The coordinates of the center of the left eye.

Point!

The coordinates of the center of the mouth.

Point!

The coordinates of the center of the right eye.

Int

The confidence level for the detection of the face.

String

Represent the Face as a string for debugging purposes.

Constants

ID_UNSUPPORTED

Added in API level 21
static val ID_UNSUPPORTED: Int

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

Value: -1

See Also

SCORE_MAX

Added in API level 21
static val SCORE_MAX: Int

The maximum possible value for the confidence level.

Value: 100

See Also

SCORE_MIN

Added in API level 21
static val SCORE_MIN: Int

The minimum possible value for the confidence level.

Value: 1

See Also

Public methods

getBounds

Added in API level 21
fun getBounds(): Rect!

Bounds of the face.

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

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

getId

Added in API level 21
fun getId(): Int

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 and may not be supported on all devices. If the id is {@value #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 CaptureResult.STATISTICS_FACE_DETECT_MODE as CameraMetadata.STATISTICS_FACE_DETECT_MODE_SIMPLE in CaptureResult, the face id of each face is expected to be {@value #ID_UNSUPPORTED}.

This value will either be {@value #ID_UNSUPPORTED} or otherwise greater than 0.

See Also

getLeftEyePosition

Added in API level 21
fun getLeftEyePosition(): Point!

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 and 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 {@value #ID_UNSUPPORTED}.

Return
Point! The left eye position, or null if unknown.

getMouthPosition

Added in API level 21
fun getMouthPosition(): Point!

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 and 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 {@value #ID_UNSUPPORTED}.

Return
Point! The mouth position, or null if unknown.

getRightEyePosition

Added in API level 21
fun getRightEyePosition(): Point!

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 and 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 {@value #ID_UNSUPPORTED}.

Return
Point! The right eye position, or null if unknown.

getScore

Added in API level 21
fun getScore(): Int

The confidence level for the detection of the face.

The range is {@value #SCORE_MIN} to {@value #SCORE_MAX}. {@value #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 {@value #SCORE_MAX} is recommended.

Return
Int Value is between SCORE_MIN and SCORE_MAX inclusive

toString

Added in API level 21
fun toString(): String

Represent the Face as a string for debugging purposes.

Return
String a string representation of the object.