Face

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

Describes a face detected in an image.
Requires API level 21 (Android 5.0, Lollipop)

Summary

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
Point!

The coordinates of the center of the left eye.

Point!

The coordinates of the center of the mouth.

String

Represent the Face as a string for debugging purposes.

Int

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

Point!

The coordinates of the center of the right eye.

Rect!

Bounds of the face.

Int

The confidence level for the detection of the face.

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.
Requires API level 21 (Android 5.0, Lollipop)

Value: -1

SCORE_MAX

added in API level 21
static val SCORE_MAX: Int

The maximum possible value for the confidence level.
Requires API level 21 (Android 5.0, Lollipop)

Value: 100

See Also

SCORE_MIN

added in API level 21
static val SCORE_MIN: Int

The minimum possible value for the confidence level.
Requires API level 21 (Android 5.0, Lollipop)

Value: 1

See Also

Public methods

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, 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}.


Requires API level 21 (Android 5.0, Lollipop)
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, 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}.


Requires API level 21 (Android 5.0, Lollipop)
Return
Point!: The mouth position, or null if unknown.

toString

added in API level 21
fun toString(): String

Represent the Face as a string for debugging purposes.
Requires API level 21 (Android 5.0, Lollipop)

Return
String: a string representation of the object.

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, 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.


Requires API level 21 (Android 5.0, Lollipop)

See Also

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, 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}.


Requires API level 21 (Android 5.0, Lollipop)
Return
Point!: The right eye position, or null if unknown.

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 the Rectangle value other than it is not-null.


Requires API level 21 (Android 5.0, Lollipop)

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.


Requires API level 21 (Android 5.0, Lollipop)