Face.Builder

public static final class Face.Builder
extends Object

java.lang.Object
   ↳ 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()
Builder(Face current)

Public methods

Face build()

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

Face.Builder setBounds(Rect bounds)

Bounds of the face.

Face.Builder setId(int id)

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

Face.Builder setLeftEyePosition(Point leftEyePosition)

The coordinates of the center of the left eye.

Face.Builder setMouthPosition(Point mouthPosition)

The coordinates of the center of the mouth.

Face.Builder setRightEyePosition(Point rightEyePosition)

The coordinates of the center of the right eye.

Face.Builder setScore(int score)

The confidence level for the detection of the face.

Inherited methods

Public constructors

Builder

Added in API level 34
public Builder ()

Builder

Added in API level 34
public Builder (Face current)

Parameters
current Face: This value cannot be null.

Public methods

build

Added in API level 34
public Face build ()

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

Returns
Face A Face. This value cannot be null.

setBounds

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

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.

Returns
Face.Builder This builder.

setId

Added in API level 34
public Face.Builder setId (int id)

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

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

Parameters
id int: A unique ID per face visible to the tracker.

Returns
Face.Builder This builder.

setLeftEyePosition

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

The coordinates of the center of the left eye.

The coordinates should be in the same space as the ones for setBounds(Rect). 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(int) is called with .ID_UNSUPPORTED.

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

Returns
Face.Builder This builder.

setMouthPosition

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

The coordinates of the center of the mouth.

The coordinates should be in the same space as the ones for setBounds(Rect). 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(int) is called with .ID_UNSUPPORTED.

Parameters
mouthPosition Point: The position of the mouth. This value cannot be null.

Returns
Face.Builder This builder.

setRightEyePosition

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

The coordinates of the center of the right eye.

The coordinates should be in the same space as the ones for setBounds(Rect).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(int) is called with .ID_UNSUPPORTED.

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

Returns
Face.Builder This builder.

setScore

Added in API level 34
public Face.Builder setScore (int score)

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.

Parameters
score int: Confidence level between .SCORE_MIN-.SCORE_MAX. Value is between SCORE_MIN and SCORE_MAX inclusive

Returns
Face.Builder This builder. This value cannot be null.