Performs face detection on images.
Signature:
export declare class FaceDetector extends VisionTaskRunner
Extends: VisionTaskRunner
Methods
| Method | Modifiers | Description |
|---|---|---|
| createFromModelBuffer(wasmFileset, modelAssetBuffer) | static |
Initializes the Wasm runtime and creates a new face detector based on the provided model asset buffer. |
| createFromModelPath(wasmFileset, modelAssetPath) | static |
Initializes the Wasm runtime and creates a new face detector based on the path to the model asset. |
| createFromOptions(wasmFileset, faceDetectorOptions) | static |
Initializes the Wasm runtime and creates a new face detector from the provided options. |
| detect(image, imageProcessingOptions) | Performs face detection on the provided single image and waits synchronously for the response. Only use this method when the FaceDetector is created with running mode image. |
|
| detectForVideo(videoFrame, timestamp, imageProcessingOptions) | Performs face detection on the provided video frame and waits synchronously for the response. Only use this method when the FaceDetector is created with running mode video. |
|
| setOptions(options) | Sets new options for the FaceDetector.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. |
FaceDetector.createFromModelBuffer()
Initializes the Wasm runtime and creates a new face detector based on the provided model asset buffer.
Signature:
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<FaceDetector>;
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<FaceDetector>
FaceDetector.createFromModelPath()
Initializes the Wasm runtime and creates a new face detector based on the path to the model asset.
Signature:
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<FaceDetector>;
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<FaceDetector>
FaceDetector.createFromOptions()
Initializes the Wasm runtime and creates a new face detector from the provided options.
Signature:
static createFromOptions(wasmFileset: WasmFileset, faceDetectorOptions: FaceDetectorOptions): Promise<FaceDetector>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| faceDetectorOptions | FaceDetectorOptions | The options for the FaceDetector. Note that either a path to the model asset or a model buffer needs to be provided (via baseOptions). |
Returns:
Promise<FaceDetector>
FaceDetector.detect()
Performs face detection on the provided single image and waits synchronously for the response. Only use this method when the FaceDetector is created with running mode image.
Signature:
detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
Parameters
| Parameter | Type | Description |
|---|---|---|
| image | ImageSource | An image to process. |
| imageProcessingOptions | ImageProcessingOptions | the ImageProcessingOptions specifying how to process the input image before running inference. A result containing the list of detected faces. |
Returns:
FaceDetector.detectForVideo()
Performs face detection on the provided video frame and waits synchronously for the response. Only use this method when the FaceDetector is created with running mode video.
Signature:
detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;
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. A result containing the list of detected faces. |
Returns:
FaceDetector.setOptions()
Sets new options for the FaceDetector.
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: FaceDetectorOptions): Promise<void>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| options | FaceDetectorOptions | The options for the FaceDetector. |
Returns:
Promise<void>