Added in API level 34

Builder


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

Builds a Face object.

This builder is public to allow for easier application testing by creating custom object instances. It's not necessary to construct these objects during normal use of the camera API.

Summary

Public constructors

Builder(current: Face)

Public methods
Face

Returns an instance of Face created from the fields set on this builder.

Face.Builder
setBounds(bounds: Rect)

Bounds of the face.

Face.Builder
setId(id: Int)

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

Face.Builder
setLeftEyePosition(leftEyePosition: Point)

The coordinates of the center of the left eye.

Face.Builder
setMouthPosition(mouthPosition: Point)

The coordinates of the center of the mouth.

Face.Builder
setRightEyePosition(rightEyePosition: Point)

The coordinates of the center of the right eye.

Face.Builder
setScore(score: Int)

The confidence level for the detection of the face.

Public constructors

Builder

Added in API level 34
Builder()

Builder

Added in API level 34
Builder(current: Face)
Parameters
current Face: This value cannot be null.

Public methods

build

Added in API level 34
fun build(): Face

Returns an instance of Face created from the fields set on this builder.

Return
Face A Face. This value cannot be null.

setBounds

Added in API level 34
fun setBounds(bounds: Rect): Face.Builder

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.

Parameters
bounds Rect: Bounds of the face. This value cannot be null.
Return
Face.Builder This builder.

setId

Added in API level 34
fun setId(id: Int): Face.Builder

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 should 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 should either be {@value #ID_UNSUPPORTED} or otherwise greater than 0.

Parameters
id Int: A unique ID per face visible to the tracker.
Return
Face.Builder This builder.

See Also

setLeftEyePosition

Added in API level 34
fun setLeftEyePosition(leftEyePosition: Point): Face.Builder

The coordinates of the center of the left eye.

The coordinates should be in the same space as the ones for setBounds. This is an optional field and may not be supported on all devices. If not supported, the value should always be unset or set to null. This value should always be null if setId is called with {@value #ID_UNSUPPORTED}.

Parameters
leftEyePosition Point: The position of the left eye. This value cannot be null.
Return
Face.Builder This builder.

setMouthPosition

Added in API level 34
fun setMouthPosition(mouthPosition: Point): Face.Builder

The coordinates of the center of the mouth.

The coordinates should be in the same space as the ones for setBounds. This is an optional field and may not be supported on all devices. If not supported, the value should always be set to null. This value should always be null if setId is called with {@value #ID_UNSUPPORTED}.

Parameters
mouthPosition Point: The position of the mouth. This value cannot be null.
Return
Face.Builder This builder.

setRightEyePosition

Added in API level 34
fun setRightEyePosition(rightEyePosition: Point): Face.Builder

The coordinates of the center of the right eye.

The coordinates should be in the same space as the ones for setBounds.This is an optional field and may not be supported on all devices. If not supported, the value should always be set to null. This value should always be null if setId is called with {@value #ID_UNSUPPORTED}.

Parameters
rightEyePosition Point: The position of the right eye. This value cannot be null.
Return
Face.Builder This builder.

setScore

Added in API level 34
fun setScore(score: Int): Face.Builder

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.

Parameters
score Int: Confidence level between {@value #SCORE_MIN}-{@value #SCORE_MAX}. Value is between SCORE_MIN and SCORE_MAX inclusive
Return
Face.Builder This builder. This value cannot be null.