# Face.Builder

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/hardware/camera2/params/Face.Builder "View this page in Java")  

```
class Builder
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                               ||
| ↳ | [android.hardware.camera2.params.Face.Builder](https://developer.android.com/reference/kotlin/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](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#Builder())`()` <br />                                                                                                                                             |
| [Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#Builder(android.hardware.camera2.params.Face))`(`current:` `[Face](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face)`)` <br /> |

|                                                                                                                                                                                                               Public methods                                                                                                                                                                                                               ||
|--------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Face](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face)                  | [build](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#build())`()` Returns an instance of`Face`created from the fields set on this builder.                                                                                                                                    |
| [Face.Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#) | [setBounds](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#setBounds(android.graphics.Rect))`(`bounds:` `[Rect](https://developer.android.com/reference/kotlin/android/graphics/Rect.html#)`)` Bounds of the face.                                                              |
| [Face.Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#) | [setId](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#setId(kotlin.Int))`(`id:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` An unique id per face while the face is visible to the tracker.                                                 |
| [Face.Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#) | [setLeftEyePosition](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#setLeftEyePosition(android.graphics.Point))`(`leftEyePosition:` `[Point](https://developer.android.com/reference/kotlin/android/graphics/Point.html#)`)` The coordinates of the center of the left eye.     |
| [Face.Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#) | [setMouthPosition](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#setMouthPosition(android.graphics.Point))`(`mouthPosition:` `[Point](https://developer.android.com/reference/kotlin/android/graphics/Point.html#)`)` The coordinates of the center of the mouth.              |
| [Face.Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#) | [setRightEyePosition](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#setRightEyePosition(android.graphics.Point))`(`rightEyePosition:` `[Point](https://developer.android.com/reference/kotlin/android/graphics/Point.html#)`)` The coordinates of the center of the right eye. |
| [Face.Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#) | [setScore](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#setScore(kotlin.Int))`(`score:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` The confidence level for the detection of the face.                                                    |

## Public constructors

### Builder

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder()
```  

### Builder

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(current: Face)
```

|                                                             Parameters                                                             ||
|-----------|-------------------------------------------------------------------------------------------------------------------------|
| `current` | [Face](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face):This value cannot be`null`. |

## Public methods

### build

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): Face
```

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

|                                                              Return                                                              ||
|---------------------------------------------------------------------------------------------|-------------------------------------|
| [Face](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face) | A Face. This value cannot be`null`. |

### setBounds

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setBounds(bounds: Rect): Face.Builder
```

Bounds of the face.

A rectangle relative to the sensor's[CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraCharacteristics.html#SENSOR_INFO_ACTIVE_ARRAY_SIZE:android.hardware.camera2.CameraCharacteristics.Key), 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](https://developer.android.com/reference/kotlin/android/graphics/Rect.html#):Bounds of the face. This value cannot be`null`. |

|                                                           Return                                                            ||
|--------------------------------------------------------------------------------------------------------------|---------------|
| [Face.Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#) | This builder. |

### setId

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/reference/kotlin/android/hardware/camera2/CaptureResult.html#STATISTICS_FACE_DETECT_MODE:android.hardware.camera2.CaptureResult.Key)as[CameraMetadata.STATISTICS_FACE_DETECT_MODE_SIMPLE](https://developer.android.com/reference/kotlin/android/hardware/camera2/CameraMetadata.html#STATISTICS_FACE_DETECT_MODE_SIMPLE:kotlin.Int)in[CaptureResult](https://developer.android.com/reference/kotlin/android/hardware/camera2/CaptureResult.html#), 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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):A unique ID per face visible to the tracker. |

|                                                           Return                                                            ||
|--------------------------------------------------------------------------------------------------------------|---------------|
| [Face.Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#) | This builder. |

**See Also**

- [#ID_UNSUPPORTED](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face#ID_UNSUPPORTED:kotlin.Int)  

### setLeftEyePosition

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#setBounds(android.graphics.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](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#setId(kotlin.Int))is called with {@value #ID_UNSUPPORTED}.

|                                                                            Parameters                                                                             ||
|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| `leftEyePosition` | [Point](https://developer.android.com/reference/kotlin/android/graphics/Point.html#):The position of the left eye. This value cannot be`null`. |

|                                                           Return                                                            ||
|--------------------------------------------------------------------------------------------------------------|---------------|
| [Face.Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#) | This builder. |

### setMouthPosition

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#setBounds(android.graphics.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](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#setId(kotlin.Int))is called with {@value #ID_UNSUPPORTED}.

<br />

|                                                                          Parameters                                                                          ||
|-----------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| `mouthPosition` | [Point](https://developer.android.com/reference/kotlin/android/graphics/Point.html#):The position of the mouth. This value cannot be`null`. |

|                                                           Return                                                            ||
|--------------------------------------------------------------------------------------------------------------|---------------|
| [Face.Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#) | This builder. |

### setRightEyePosition

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#setBounds(android.graphics.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](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#setId(kotlin.Int))is called with {@value #ID_UNSUPPORTED}.

|                                                                             Parameters                                                                              ||
|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `rightEyePosition` | [Point](https://developer.android.com/reference/kotlin/android/graphics/Point.html#):The position of the right eye. This value cannot be`null`. |

|                                                           Return                                                            ||
|--------------------------------------------------------------------------------------------------------------|---------------|
| [Face.Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#) | This builder. |

### setScore

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
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](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Confidence level between {@value #SCORE_MIN}-{@value #SCORE_MAX}. Value is between[android.hardware.camera2.params.Face#SCORE_MIN](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face#SCORE_MIN:kotlin.Int)and[android.hardware.camera2.params.Face#SCORE_MAX](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face#SCORE_MAX:kotlin.Int)inclusive |

|                                                                         Return                                                                          ||
|--------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [Face.Builder](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face.Builder#) | This builder. This value cannot be`null`. |

**See Also**

- [#SCORE_MAX](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face#SCORE_MAX:kotlin.Int)
- [#SCORE_MIN](https://developer.android.com/reference/kotlin/android/hardware/camera2/params/Face#SCORE_MIN:kotlin.Int)