Performs face landmarks detection on images. This API expects a pre-trained face landmarker model asset bundle.
Signature:
export declare class FaceLandmarker extends VisionTaskRunner
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| FACE_LANDMARKS_LIPS | static |
Connection[] | Landmark connections to draw the connection between a face's lips. |
| FACE_LANDMARKS_LEFT_EYE | static |
Connection[] | Landmark connections to draw the connection between a face's left eye. |
| FACE_LANDMARKS_LEFT_EYEBROW | static |
Connection[] | Landmark connections to draw the connection between a face's left eyebrow. |
| FACE_LANDMARKS_LEFT_IRIS | static |
Connection[] | Landmark connections to draw the connection between a face's left iris. |
| FACE_LANDMARKS_RIGHT_EYE | static |
Connection[] | Landmark connections to draw the connection between a face's right eye. |
| FACE_LANDMARKS_RIGHT_EYEBROW | static |
Connection[] | Landmark connections to draw the connection between a face's right eyebrow. |
| FACE_LANDMARKS_RIGHT_IRIS | static |
Connection[] | Landmark connections to draw the connection between a face's right iris. |
| FACE_LANDMARKS_FACE_OVAL | static |
Connection[] | Landmark connections to draw the face's oval. |
| FACE_LANDMARKS_CONTOURS | static |
Connection[] | Landmark connections to draw the face's contour. |
| FACE_LANDMARKS_TESSELATION | static |
Connection[] | Landmark connections to draw the face's tesselation. |
Methods
| Method | Modifiers | Description |
|---|---|---|
| createFromOptions(wasmFileset, faceLandmarkerOptions) | static |
Initializes the Wasm runtime and creates a new FaceLandmarker from the provided options. |
| createFromModelBuffer(wasmFileset, modelAssetBuffer) | static |
Initializes the Wasm runtime and creates a new FaceLandmarker based on the provided model asset buffer. |
| createFromModelPath(wasmFileset, modelAssetPath) | static |
Initializes the Wasm runtime and creates a new FaceLandmarker based on the path to the model asset. |
| setOptions(options) | 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. |
|
| detect(image, imageProcessingOptions) | 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. |
|
| detectForVideo(videoFrame, timestamp, imageProcessingOptions) | 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. |
FaceLandmarker.FACE_LANDMARKS_LIPS
Landmark connections to draw the connection between a face's lips.
Signature:
static FACE_LANDMARKS_LIPS: 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_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_FACE_OVAL
Landmark connections to draw the face's oval.
Signature:
static FACE_LANDMARKS_FACE_OVAL: Connection[];
FaceLandmarker.FACE_LANDMARKS_CONTOURS
Landmark connections to draw the face's contour.
Signature:
static FACE_LANDMARKS_CONTOURS: Connection[];
FaceLandmarker.FACE_LANDMARKS_TESSELATION
Landmark connections to draw the face's tesselation.
Signature:
static FACE_LANDMARKS_TESSELATION: Connection[];
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.createFromModelBuffer()
Initializes the Wasm runtime and creates a new FaceLandmarker based on the provided model asset buffer.
Signature:
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array | ReadableStreamDefaultReader): Promise<FaceLandmarker>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetBuffer | Uint8Array | ReadableStreamDefaultReader | An array or a stream containing 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.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>
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. |
Returns:
FaceLandmarkerResult
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. |
Returns:
FaceLandmarkerResult