Skip to content

PoseDetectionOnImage

Runs pose detection once on an image file.

function PoseDetectionOnImage(
imagePath: string,
model: string,
options?: Partial<PoseDetectionOptions>
): Promise<PoseDetectionResultBundle>;
Parameter Type Description
imagePath string Path to the image on the device, for example from camera.takePhoto() or an image picker.
model string File name of a bundled pose landmarker model.
options Partial<PoseDetectionOptions> Same options as usePoseDetection. Only numPoses, the confidence thresholds, shouldOutputSegmentationMasks and delegate apply here.

A promise for a PoseDetectionResultBundle. It rejects if the image or model can’t be loaded.

const result = await PoseDetectionOnImage(photo.path, 'pose_landmarker_heavy.task', {
numPoses: 2,
});
for (const person of result.results[0]?.landmarks ?? []) {
const leftWrist = person[KnownPoseLandmarks.leftWrist];
console.log(leftWrist.x * result.inputImageWidth, leftWrist.y * result.inputImageHeight);
}

See the static images guide for more.