Performs face landmarks detection on images.
This API expects a pre-trained face landmarker model asset bundle.
Signature:
export
declare
class
FaceLandmarker
extends
VisionTaskRunner
Extends: VisionTaskRunner
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
static
|
Connection[] | Landmark connections to draw the face's contour. | |
static
|
Connection[] | Landmark connections to draw the face's oval. | |
static
|
Connection[] | Landmark connections to draw the connection between a face's left eye. | |
static
|
Connection[] | Landmark connections to draw the connection between a face's left eyebrow. | |
static
|
Connection[] | Landmark connections to draw the connection between a face's left iris. | |
static
|
Connection[] | Landmark connections to draw the connection between a face's lips. | |
static
|
Connection[] | Landmark connections to draw the connection between a face's right eye. | |
static
|
Connection[] | Landmark connections to draw the connection between a face's right eyebrow. | |
static
|
Connection[] | Landmark connections to draw the connection between a face's right iris. | |
static
|
Connection[] | Landmark connections to draw the face's tesselation. |
Methods
| Method | Modifiers | Description |
|---|---|---|
static
|
Initializes the Wasm runtime and creates a new FaceLandmarker
based on the provided model asset buffer. |
|
static
|
Initializes the Wasm runtime and creates a new FaceLandmarker
based on the path to the model asset. |
|
static
|
Initializes the Wasm runtime and creates a new FaceLandmarker
from the provided options. |
|
Performs face landmarks detection on the provided single image and waits synchronously for the response. Only use this method when the FaceLandmarker is created with running mode image
. |
||
Performs face landmarks detection on the provided video frame and waits synchronously for the response. Only use this method when the FaceLandmarker is created with running mode video
. |
||
Sets new options for this FaceLandmarker
.Calling setOptions()
with a subset of options only affects those options. You can reset an option back to its default value by explicitly setting it to undefined
. |
FaceLandmarker.FACE_LANDMARKS_CONTOURS
Landmark connections to draw the face's contour.
Signature:
static
FACE_LANDMARKS_CONTOURS
:
Connection
[];
FaceLandmarker.FACE_LANDMARKS_FACE_OVAL
Landmark connections to draw the face's oval.
Signature:
static
FACE_LANDMARKS_FACE_OVAL
:
Connection
[];
FaceLandmarker.FACE_LANDMARKS_LEFT_EYE
Landmark connections to draw the connection between a face's left eye.
Signature:
static
FACE_LANDMARKS_LEFT_EYE
:
Connection
[];
FaceLandmarker.FACE_LANDMARKS_LEFT_EYEBROW
Landmark connections to draw the connection between a face's left eyebrow.
Signature:
static
FACE_LANDMARKS_LEFT_EYEBROW
:
Connection
[];
FaceLandmarker.FACE_LANDMARKS_LEFT_IRIS
Landmark connections to draw the connection between a face's left iris.
Signature:
static
FACE_LANDMARKS_LEFT_IRIS
:
Connection
[];
FaceLandmarker.FACE_LANDMARKS_LIPS
Landmark connections to draw the connection between a face's lips.
Signature:
static
FACE_LANDMARKS_LIPS
:
Connection
[];
FaceLandmarker.FACE_LANDMARKS_RIGHT_EYE
Landmark connections to draw the connection between a face's right eye.
Signature:
static
FACE_LANDMARKS_RIGHT_EYE
:
Connection
[];
FaceLandmarker.FACE_LANDMARKS_RIGHT_EYEBROW
Landmark connections to draw the connection between a face's right eyebrow.
Signature:
static
FACE_LANDMARKS_RIGHT_EYEBROW
:
Connection
[];
FaceLandmarker.FACE_LANDMARKS_RIGHT_IRIS
Landmark connections to draw the connection between a face's right iris.
Signature:
static
FACE_LANDMARKS_RIGHT_IRIS
:
Connection
[];
FaceLandmarker.FACE_LANDMARKS_TESSELATION
Landmark connections to draw the face's tesselation.
Signature:
static
FACE_LANDMARKS_TESSELATION
:
Connection
[];
FaceLandmarker.createFromModelBuffer()
Initializes the Wasm runtime and creates a new FaceLandmarker
based on the provided model asset buffer.
Signature:
static
createFromModelBuffer
(
wasmFileset
:
WasmFileset
,
modelAssetBuffer
:
Uint8Array
)
:
Promise<FaceLandmarker>
;
Parameters
| Parameter | Type | Description |
|---|---|---|
|
wasmFileset
|
WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
|
modelAssetBuffer
|
Uint8Array | A binary representation of the model. |
Returns:
Promise< FaceLandmarker >
FaceLandmarker.createFromModelPath()
Initializes the Wasm runtime and creates a new FaceLandmarker
based on the path to the model asset.
Signature:
static
createFromModelPath
(
wasmFileset
:
WasmFileset
,
modelAssetPath
:
string
)
:
Promise<FaceLandmarker>
;
Parameters
| Parameter | Type | Description |
|---|---|---|
|
wasmFileset
|
WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
|
modelAssetPath
|
string | The path to the model asset. |
Returns:
Promise< FaceLandmarker >
FaceLandmarker.createFromOptions()
Initializes the Wasm runtime and creates a new FaceLandmarker
from the provided options.
Signature:
static
createFromOptions
(
wasmFileset
:
WasmFileset
,
faceLandmarkerOptions
:
FaceLandmarkerOptions
)
:
Promise<FaceLandmarker>
;
Parameters
| Parameter | Type | Description |
|---|---|---|
|
wasmFileset
|
WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
|
faceLandmarkerOptions
|
FaceLandmarkerOptions | The options for the FaceLandmarker. Note that either a path to the model asset or a model buffer needs to be provided (via baseOptions
). |
Returns:
Promise< FaceLandmarker >
FaceLandmarker.detect()
Performs face landmarks detection on the provided single image and waits synchronously for the response. Only use this method when the FaceLandmarker is created with running mode image
.
Signature:
detect
(
image
:
ImageSource
,
imageProcessingOptions?
:
ImageProcessingOptions
)
:
FaceLandmarkerResult
;
Parameters
| Parameter | Type | Description |
|---|---|---|
|
image
|
ImageSource | An image to process. |
|
imageProcessingOptions
|
ImageProcessingOptions | the ImageProcessingOptions
specifying how to process the input image before running inference. The detected face landmarks. |
Returns:
FaceLandmarker.detectForVideo()
Performs face landmarks detection on the provided video frame and waits synchronously for the response. Only use this method when the FaceLandmarker is created with running mode video
.
Signature:
detectForVideo
(
videoFrame
:
ImageSource
,
timestamp
:
number
,
imageProcessingOptions?
:
ImageProcessingOptions
)
:
FaceLandmarkerResult
;
Parameters
| Parameter | Type | Description |
|---|---|---|
|
videoFrame
|
ImageSource | A video frame to process. |
|
timestamp
|
number | The timestamp of the current frame, in ms. |
|
imageProcessingOptions
|
ImageProcessingOptions | the ImageProcessingOptions
specifying how to process the input image before running inference. The detected face landmarks. |
Returns:
FaceLandmarker.setOptions()
Sets new options for this FaceLandmarker
.
Calling setOptions()
with a subset of options only affects those options. You can reset an option back to its default value by explicitly setting it to undefined
.
Signature:
setOptions
(
options
:
FaceLandmarkerOptions
)
:
Promise<void>
;
Parameters
| Parameter | Type | Description |
|---|---|---|
|
options
|
FaceLandmarkerOptions | The options for the face landmarker. |
Returns:
Promise<void>

