# FaceMeshDetector

public interface **FaceMeshDetector** extends Detector\<[List](https://developer.android.com/reference/java/util/List.html)\<[FaceMesh](https://developers.google.com/android/reference/com/google/mlkit/vision/facemesh/FaceMesh.md.txt)\>\> A `FaceMeshDetection`
client for finding `FaceMesh`s in a
supplied image, which works best in selfie use case where face is within \~2 meters, or \~6.5
feet from the camera.

The `FaceMeshDetection`
provides two functionalities. When `
FaceMeshDetectorOptions.BOUNDING_BOX_ONLY` is selected, it detects face bounding
box in selfie image with low latency(i.e. 12ms for a 640 \* 360 image on Pixel 3). When
`FaceMeshDetectorOptions.FACE_MESH`
is selected, it detects at most 2 faces and for each detected face it provides extra 468 3D
points and its triangle information.

A `FaceMeshDetector`
is created via `
FaceMeshDetection.getClient(FaceMeshDetectorOptions)` or `FaceMeshDetection.getClient()`,
if you wish to use the default options. For example, the code below creates a `FaceMeshDetector`
client with default options.

    FaceMeshDetector faceMeshDetector = FaceMeshDetection.getClient();
     
To perform face detection in an image, you first need to create an instance of `
InputImage` from a `Bitmap`, `ByteBuffer`, `Image` etc. See `InputImage` documentation for more details. For example, the code below creates an `InputImage` from a `Bitmap`.

    InputImage image = InputImage.fromBitmap(bitmap, rotationDegrees);
     
Then the code below can detect faces in the supplied `InputImage`.

    Task<List<FaceMesh>> task = faceMeshDetector.process(image);
     task.addOnSuccessListener(...).addOnFailureListener(...);
     
### Public Method Summary

|---|---|
| abstract void | [close](https://developers.google.com/android/reference/com/google/mlkit/vision/facemesh/FaceMeshDetector.md.txt#close())() Closes the detector and releases its resources. |
| abstract Task\<[List](https://developer.android.com/reference/java/util/List.html)\<[FaceMesh](https://developers.google.com/android/reference/com/google/mlkit/vision/facemesh/FaceMesh.md.txt)\>\> | [process](https://developers.google.com/android/reference/com/google/mlkit/vision/facemesh/FaceMeshDetector.md.txt#process(com.google.android.odml.image.MlImage))([MlImage](https://developers.google.com/android/reference/com/google/android/odml/image/MlImage.md.txt) image) Detects human faces from the supplied image. |
| abstract Task\<[List](https://developer.android.com/reference/java/util/List.html)\<[FaceMesh](https://developers.google.com/android/reference/com/google/mlkit/vision/facemesh/FaceMesh.md.txt)\>\> | [process](https://developers.google.com/android/reference/com/google/mlkit/vision/facemesh/FaceMeshDetector.md.txt#process(com.google.mlkit.vision.common.InputImage))(InputImage image) Detects face mesh from the supplied image. |

### Inherited Method Summary

From interface java.io.Closeable

|---|---|
| abstract void | close() |

From interface java.lang.AutoCloseable

|---|---|
| abstract void | close() |

## Public Methods

#### public abstract void **close** ()

Closes the detector and releases its resources.

#### public abstract Task\<[List](https://developer.android.com/reference/java/util/List.html)\<[FaceMesh](https://developers.google.com/android/reference/com/google/mlkit/vision/facemesh/FaceMesh.md.txt)\>\>
**process** ([MlImage](https://developers.google.com/android/reference/com/google/android/odml/image/MlImage.md.txt) image)

Detects human faces from the supplied image.

This is an experimental API in beta version.

Create an `MlImage`
object using one of `MlImage`'s
builder methods. See `MlImage`
documentation for more details.

If there is no face gets detected, the returned `Task` will
contain an empty `List`.

##### Returns

- a `Task` that asynchronously returns a `List` of detected `FaceMesh`s

#### public abstract Task\<[List](https://developer.android.com/reference/java/util/List.html)\<[FaceMesh](https://developers.google.com/android/reference/com/google/mlkit/vision/facemesh/FaceMesh.md.txt)\>\>
**process** (InputImage image)

Detects face mesh from the supplied image.

Create an `InputImage`
object using one of `InputImage`'s
factory methods. See `InputImage`
documentation for more details.

If there is no face gets detected, the returned `Task` will
contain an empty `List`.

##### Returns

- a `Task` that asynchronously returns a `List` of detected `FaceMesh`s