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 |
---|---|---|---|
FACE_LANDMARKS_CONTOURS | static |
Connection[] | Landmark connections to draw the face's contour. |
FACE_LANDMARKS_FACE_OVAL | static |
Connection[] | Landmark connections to draw the face's oval. |
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_LIPS | static |
Connection[] | Landmark connections to draw the connection between a face's lips. |
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_TESSELATION | static |
Connection[] | Landmark connections to draw the face's tesselation. |
Methods
Method | Modifiers | Description |
---|---|---|
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. |
createFromOptions(wasmFileset, faceLandmarkerOptions) | static |
Initializes the Wasm runtime and creates a new FaceLandmarker from the provided options. |
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 . |
|
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 . |
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>