Performs face landmarks detection on images.
This API expects a pre-trained face landmarks model asset bundle. See
MPImage
FaceLandmarkerResult
Nested Classes
| class | FaceLandmarker.FaceLandmarkerOptions | Options for setting up an FaceLandmarker. |
|
Fields
| public static final Set<Connection> | FACE_LANDMARKS_CONNECTORS | |
| public static final Set<Connection> | FACE_LANDMARKS_FACE_OVAL | |
| public static final Set<Connection> | FACE_LANDMARKS_LEFT_EYE | |
| public static final Set<Connection> | FACE_LANDMARKS_LEFT_EYE_BROW | |
| public static final Set<Connection> | FACE_LANDMARKS_LEFT_IRIS | |
| public static final Set<Connection> | FACE_LANDMARKS_LIPS | |
| public static final Set<Connection> | FACE_LANDMARKS_RIGHT_EYE | |
| public static final Set<Connection> | FACE_LANDMARKS_RIGHT_EYE_BROW | |
| public static final Set<Connection> | FACE_LANDMARKS_RIGHT_IRIS | |
| public static final Set<Connection> | FACE_LANDMARKS_TESSELATION |
Public Methods
| static FaceLandmarker |
createFromBuffer(Context context, ByteBuffer modelAssetBuffer)
Creates a
FaceLandmarker instance from a model asset bundle buffer and the default
FaceLandmarker.FaceLandmarkerOptions. |
| static FaceLandmarker |
createFromFile(Context context, String modelAssetPath)
Creates a
FaceLandmarker instance from a model asset bundle path and the default FaceLandmarker.FaceLandmarkerOptions. |
| static FaceLandmarker |
createFromFile(Context context, File modelAssetFile)
Creates a
FaceLandmarker instance from a model asset bundle file and the default FaceLandmarker.FaceLandmarkerOptions. |
| static FaceLandmarker |
createFromOptions(Context context, FaceLandmarker.FaceLandmarkerOptions landmarkerOptions)
Creates a
FaceLandmarker instance from a FaceLandmarker.FaceLandmarkerOptions. |
| FaceLandmarkerResult | |
| FaceLandmarkerResult |
detect(MPImage image, ImageProcessingOptions imageProcessingOptions)
Performs face landmarks detection on the provided single image.
|
| void |
detectAsync(MPImage image, ImageProcessingOptions imageProcessingOptions, long timestampMs)
Sends live image data to perform face landmarks detection, and the results will be available
via the
OutputHandler.ResultListener provided in the FaceLandmarker.FaceLandmarkerOptions. |
| void |
detectAsync(MPImage image, long timestampMs)
Sends live image data to perform face landmarks detection with default image processing
options, i.e.
|
| FaceLandmarkerResult |
detectForVideo(MPImage image, ImageProcessingOptions imageProcessingOptions, long timestampMs)
Performs face landmarks detection on the provided video frame.
|
| FaceLandmarkerResult |
detectForVideo(MPImage image, long timestampMs)
Performs face landmarks detection on the provided video frame with default image processing
options, i.e.
|
Inherited Methods
Fields
Public Methods
public static FaceLandmarker createFromBuffer (Context context, ByteBuffer modelAssetBuffer)
Creates a FaceLandmarker instance from a model asset bundle buffer and the default
FaceLandmarker.FaceLandmarkerOptions.
Parameters
| context | an Android ERROR(/Context). |
|---|---|
| modelAssetBuffer |
Throws
if there is an error during FaceLandmarker creation.
|
public static FaceLandmarker createFromFile (Context context, String modelAssetPath)
Creates a FaceLandmarker instance from a model asset bundle path and the default FaceLandmarker.FaceLandmarkerOptions.
Parameters
| context | an Android ERROR(/Context). |
|---|---|
| modelAssetPath | path to the face landmarks model with metadata in the assets. |
Throws
if there is an error during FaceLandmarker creation.
|
public static FaceLandmarker createFromFile (Context context, File modelAssetFile)
Creates a FaceLandmarker instance from a model asset bundle file and the default FaceLandmarker.FaceLandmarkerOptions.
Parameters
| context | an Android ERROR(/Context). |
|---|---|
| modelAssetFile | the face landmarks model File instance. |
Throws
| IOException | if an I/O error occurs when opening the tflite model file. |
|---|---|
if there is an error during FaceLandmarker creation.
|
public static FaceLandmarker createFromOptions (Context context, FaceLandmarker.FaceLandmarkerOptions landmarkerOptions)
Creates a FaceLandmarker instance from a FaceLandmarker.FaceLandmarkerOptions.
Parameters
| context | an Android ERROR(/Context). |
|---|---|
| landmarkerOptions | a FaceLandmarker.FaceLandmarkerOptions instance. |
Throws
if there is an error during FaceLandmarker creation.
|
public FaceLandmarkerResult detect (MPImage image)
Performs face landmarks detection on the provided single image with default image processing
options, i.e. without any rotation applied. Only use this method when the FaceLandmarker is created with ERROR(/RunningMode.IMAGE). TODO update java doc
for input image format.
FaceLandmarker supports the following color space types:
Parameters
| image | a MediaPipe MPImage object for processing. |
|---|
Throws
| if there is an internal error. |
public FaceLandmarkerResult detect (MPImage image, ImageProcessingOptions imageProcessingOptions)
Performs face landmarks detection on the provided single image. Only use this method when the
FaceLandmarker is created with ERROR(/RunningMode.IMAGE). TODO update java
doc for input image format.
FaceLandmarker supports the following color space types:
Parameters
| image | a MediaPipe MPImage object for processing. |
|---|---|
| imageProcessingOptions | the ImageProcessingOptions specifying how to process the
input image before running inference. Note that region-of-interest is not supported
by this task: specifying ImageProcessingOptions.regionOfInterest() will result in
this method throwing an IllegalArgumentException. |
Throws
| IllegalArgumentException | if the ImageProcessingOptions specify a
region-of-interest. |
|---|---|
| if there is an internal error. |
public void detectAsync (MPImage image, ImageProcessingOptions imageProcessingOptions, long timestampMs)
Sends live image data to perform face landmarks detection, and the results will be available
via the OutputHandler.ResultListener provided in the FaceLandmarker.FaceLandmarkerOptions. Only use this
method when the FaceLandmarker is created with ERROR(/RunningMode.LIVE_STREAM).
It's required to provide a timestamp (in milliseconds) to indicate when the input image is sent to the face landmarker. The input timestamps must be monotonically increasing.
FaceLandmarker supports the following color space types:
Parameters
| image | a MediaPipe MPImage object for processing. |
|---|---|
| imageProcessingOptions | the ImageProcessingOptions specifying how to process the
input image before running inference. Note that region-of-interest is not supported
by this task: specifying ImageProcessingOptions.regionOfInterest() will result in
this method throwing an IllegalArgumentException. |
| timestampMs | the input timestamp (in milliseconds). |
Throws
| IllegalArgumentException | if the ImageProcessingOptions specify a
region-of-interest. |
|---|---|
| if there is an internal error. |
public void detectAsync (MPImage image, long timestampMs)
Sends live image data to perform face landmarks detection with default image processing
options, i.e. without any rotation applied, and the results will be available via the OutputHandler.ResultListener provided in the FaceLandmarker.FaceLandmarkerOptions. Only use this method when the
FaceLandmarker is created with ERROR(/RunningMode.LIVE_STREAM).
It's required to provide a timestamp (in milliseconds) to indicate when the input image is sent to the face landmarker. The input timestamps must be monotonically increasing.
FaceLandmarker supports the following color space types:
Parameters
| image | a MediaPipe MPImage object for processing. |
|---|---|
| timestampMs | the input timestamp (in milliseconds). |
Throws
| if there is an internal error. |
public FaceLandmarkerResult detectForVideo (MPImage image, ImageProcessingOptions imageProcessingOptions, long timestampMs)
Performs face landmarks detection on the provided video frame. Only use this method when the
FaceLandmarker is created with ERROR(/RunningMode.VIDEO).
It's required to provide the video frame's timestamp (in milliseconds). The input timestamps must be monotonically increasing.
FaceLandmarker supports the following color space types:
Parameters
| image | a MediaPipe MPImage object for processing. |
|---|---|
| imageProcessingOptions | the ImageProcessingOptions specifying how to process the
input image before running inference. Note that region-of-interest is not supported
by this task: specifying ImageProcessingOptions.regionOfInterest() will result in
this method throwing an IllegalArgumentException. |
| timestampMs | the input timestamp (in milliseconds). |
Throws
| IllegalArgumentException | if the ImageProcessingOptions specify a
region-of-interest. |
|---|---|
| if there is an internal error. |
public FaceLandmarkerResult detectForVideo (MPImage image, long timestampMs)
Performs face landmarks detection on the provided video frame with default image processing
options, i.e. without any rotation applied. Only use this method when the FaceLandmarker is created with ERROR(/RunningMode.VIDEO).
It's required to provide the video frame's timestamp (in milliseconds). The input timestamps must be monotonically increasing.
FaceLandmarker supports the following color space types:
Parameters
| image | a MediaPipe MPImage object for processing. |
|---|---|
| timestampMs | the input timestamp (in milliseconds). |
Throws
| if there is an internal error. |