PoseLandmarker class

Performs pose landmarks detection on images.

Signature:

export declare class PoseLandmarker extends VisionTaskRunner 

Extends: VisionTaskRunner

Properties

PropertyModifiersTypeDescription
POSE_CONNECTIONSstaticConnection[]An array containing the pairs of pose landmark indices to be rendered with connections.

Methods

MethodModifiersDescription
createFromModelBuffer(wasmFileset, modelAssetBuffer)staticInitializes the Wasm runtime and creates a new PoseLandmarker based on the provided model asset buffer.
createFromModelPath(wasmFileset, modelAssetPath)staticInitializes the Wasm runtime and creates a new PoseLandmarker based on the path to the model asset.
createFromOptions(wasmFileset, poseLandmarkerOptions)staticInitializes the Wasm runtime and creates a new PoseLandmarker from the provided options.
detect(image, callback)Performs pose detection on the provided single image and invokes the callback with the response. The method returns synchronously once the callback returns. Only use this method when the PoseLandmarker is created with running mode image.
detect(image, imageProcessingOptions, callback)Performs pose detection on the provided single image and invokes the callback with the response. The method returns synchronously once the callback returns. Only use this method when the PoseLandmarker is created with running mode image.
detect(image)Performs pose detection on the provided single image and waits synchronously for the response. This method creates a copy of the resulting masks and should not be used in high-throughput applications. Only use this method when the PoseLandmarker is created with running mode image.
detect(image, imageProcessingOptions)Performs pose detection on the provided single image and waits synchronously for the response. This method creates a copy of the resulting masks and should not be used in high-throughput applications. Only use this method when the PoseLandmarker is created with running mode image.
detectForVideo(videoFrame, timestamp, callback)Performs pose detection on the provided video frame and invokes the callback with the response. The method returns synchronously once the callback returns. Only use this method when the PoseLandmarker is created with running mode video.
detectForVideo(videoFrame, timestamp, imageProcessingOptions, callback)Performs pose detection on the provided video frame and invokes the callback with the response. The method returns synchronously once the callback returns. Only use this method when the PoseLandmarker is created with running mode video.
detectForVideo(videoFrame, timestamp)Performs pose detection on the provided video frame and returns the result. This method creates a copy of the resulting masks and should not be used in high-throughput applications. Only use this method when the PoseLandmarker is created with running mode video.
detectForVideo(videoFrame, timestamp, imageProcessingOptions)Performs pose detection on the provided video frame and returns the result. This method creates a copy of the resulting masks and should not be used in high-throughput applications. The method returns synchronously once the callback returns. Only use this method when the PoseLandmarker is created with running mode video.
setOptions(options)Sets new options for this PoseLandmarker.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.

PoseLandmarker.POSE_CONNECTIONS

An array containing the pairs of pose landmark indices to be rendered with connections.

Signature:

static POSE_CONNECTIONS: Connection[];

PoseLandmarker.createFromModelBuffer()

Initializes the Wasm runtime and creates a new PoseLandmarker based on the provided model asset buffer.

Signature:

static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<PoseLandmarker>;

Parameters

ParameterTypeDescription
wasmFilesetWasmFilesetA configuration object that provides the location of the Wasm binary and its loader.
modelAssetBufferUint8ArrayA binary representation of the model.

Returns:

Promise<PoseLandmarker>

PoseLandmarker.createFromModelPath()

Initializes the Wasm runtime and creates a new PoseLandmarker based on the path to the model asset.

Signature:

static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<PoseLandmarker>;

Parameters

ParameterTypeDescription
wasmFilesetWasmFilesetA configuration object that provides the location of the Wasm binary and its loader.
modelAssetPathstringThe path to the model asset.

Returns:

Promise<PoseLandmarker>

PoseLandmarker.createFromOptions()

Initializes the Wasm runtime and creates a new PoseLandmarker from the provided options.

Signature:

static createFromOptions(wasmFileset: WasmFileset, poseLandmarkerOptions: PoseLandmarkerOptions): Promise<PoseLandmarker>;

Parameters

ParameterTypeDescription
wasmFilesetWasmFilesetA configuration object that provides the location of the Wasm binary and its loader.
poseLandmarkerOptionsPoseLandmarkerOptionsThe options for the PoseLandmarker. Note that either a path to the model asset or a model buffer needs to be provided (via baseOptions).

Returns:

Promise<PoseLandmarker>

PoseLandmarker.detect()

Performs pose detection on the provided single image and invokes the callback with the response. The method returns synchronously once the callback returns. Only use this method when the PoseLandmarker is created with running mode image.

Signature:

detect(image: ImageSource, callback: PoseLandmarkerCallback): void;

Parameters

ParameterTypeDescription
imageImageSourceAn image to process.
callbackPoseLandmarkerCallbackThe callback that is invoked with the result. The lifetime of the returned masks is only guaranteed for the duration of the callback.

Returns:

void

PoseLandmarker.detect()

Performs pose detection on the provided single image and invokes the callback with the response. The method returns synchronously once the callback returns. Only use this method when the PoseLandmarker is created with running mode image.

Signature:

detect(image: ImageSource, imageProcessingOptions: ImageProcessingOptions, callback: PoseLandmarkerCallback): void;

Parameters

ParameterTypeDescription
imageImageSourceAn image to process.
imageProcessingOptionsImageProcessingOptionsthe ImageProcessingOptions specifying how to process the input image before running inference.
callbackPoseLandmarkerCallbackThe callback that is invoked with the result. The lifetime of the returned masks is only guaranteed for the duration of the callback.

Returns:

void

PoseLandmarker.detect()

Performs pose detection on the provided single image and waits synchronously for the response. This method creates a copy of the resulting masks and should not be used in high-throughput applications. Only use this method when the PoseLandmarker is created with running mode image.

Signature:

detect(image: ImageSource): PoseLandmarkerResult;

Parameters

ParameterTypeDescription
imageImageSourceAn image to process. The landmarker result. Any masks are copied to avoid lifetime limits. The detected pose landmarks.

Returns:

PoseLandmarkerResult

PoseLandmarker.detect()

Performs pose detection on the provided single image and waits synchronously for the response. This method creates a copy of the resulting masks and should not be used in high-throughput applications. Only use this method when the PoseLandmarker is created with running mode image.

Signature:

detect(image: ImageSource, imageProcessingOptions: ImageProcessingOptions): PoseLandmarkerResult;

Parameters

ParameterTypeDescription
imageImageSourceAn image to process. The landmarker result. Any masks are copied to avoid lifetime limits. The detected pose landmarks.
imageProcessingOptionsImageProcessingOptions

Returns:

PoseLandmarkerResult

PoseLandmarker.detectForVideo()

Performs pose detection on the provided video frame and invokes the callback with the response. The method returns synchronously once the callback returns. Only use this method when the PoseLandmarker is created with running mode video.

Signature:

detectForVideo(videoFrame: ImageSource, timestamp: number, callback: PoseLandmarkerCallback): void;

Parameters

ParameterTypeDescription
videoFrameImageSourceA video frame to process.
timestampnumberThe timestamp of the current frame, in ms.
callbackPoseLandmarkerCallbackThe callback that is invoked with the result. The lifetime of the returned masks is only guaranteed for the duration of the callback.

Returns:

void

PoseLandmarker.detectForVideo()

Performs pose detection on the provided video frame and invokes the callback with the response. The method returns synchronously once the callback returns. Only use this method when the PoseLandmarker is created with running mode video.

Signature:

detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions, callback: PoseLandmarkerCallback): void;

Parameters

ParameterTypeDescription
videoFrameImageSourceA video frame to process.
timestampnumberThe timestamp of the current frame, in ms.
imageProcessingOptionsImageProcessingOptionsthe ImageProcessingOptions specifying how to process the input image before running inference.
callbackPoseLandmarkerCallbackThe callback that is invoked with the result. The lifetime of the returned masks is only guaranteed for the duration of the callback.

Returns:

void

PoseLandmarker.detectForVideo()

Performs pose detection on the provided video frame and returns the result. This method creates a copy of the resulting masks and should not be used in high-throughput applications. Only use this method when the PoseLandmarker is created with running mode video.

Signature:

detectForVideo(videoFrame: ImageSource, timestamp: number): PoseLandmarkerResult;

Parameters

ParameterTypeDescription
videoFrameImageSourceA video frame to process.
timestampnumberThe timestamp of the current frame, in ms. The landmarker result. Any masks are copied to extend the lifetime of the returned data.

Returns:

PoseLandmarkerResult

PoseLandmarker.detectForVideo()

Performs pose detection on the provided video frame and returns the result. This method creates a copy of the resulting masks and should not be used in high-throughput applications. The method returns synchronously once the callback returns. Only use this method when the PoseLandmarker is created with running mode video.

Signature:

detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions: ImageProcessingOptions): PoseLandmarkerResult;

Parameters

ParameterTypeDescription
videoFrameImageSourceA video frame to process.
timestampnumberThe timestamp of the current frame, in ms.
imageProcessingOptionsImageProcessingOptionsthe ImageProcessingOptions specifying how to process the input image before running inference. The landmarker result. Any masks are copied to extend the lifetime of the returned data.

Returns:

PoseLandmarkerResult

PoseLandmarker.setOptions()

Sets new options for this PoseLandmarker.

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: PoseLandmarkerOptions): Promise<void>;

Parameters

ParameterTypeDescription
optionsPoseLandmarkerOptionsThe options for the pose landmarker.

Returns:

Promise<void>