tool

MediaPipe pose estimation tool.

Classes

MediaPipePoseEstimationTool

MediaPipe pose estimation tool.

class MediaPipePoseEstimationTool(model_complexity=2, smooth=True, device='cpu', overwrite=False, verbose=True)[source]

Bases: PoseEstimationTool

MediaPipe pose estimation tool.

Parameters:
  • model_complexity (int) – Complexity of the model: {0, 1, 2}, higher means more FLOPs, but also more accurate results

  • smooth (bool) – Whether to temporally smooth the inference results to reduce the jitter.

  • device (str) – The device where the computation should be executed.

  • overwrite (bool) – Whether to overwrite existing files, otherwise raise an error.

  • verbose (Union[bool, int]) – Whether to execute the computation verbosely.

inference(video_path, poses_path)[source]

Runs MediaPipe pose estimation model on a video.

Parameters:
  • video_path (Union[str, Path]) – Path to the video file.

  • poses_path (Union[str, Path]) – Path to the pose archive.

Returns:

process_part(landmarks, size, n_points)[source]

Processes MediaPipe output into a simple flattened list of coordinates.

Parameters:
  • landmarks – MediaPipe landmarks.

  • size (Tuple[int, int]) – Image resolution.

  • n_points (int) – Expected number of points.

Return type:

List[float]

Returns:

Processed keypoint coordinates.

process_pose(results, size)[source]

Process all the parts estimated by MediaPipe, e.g. body, face, hands.

Parameters:
  • results – MediaPipe output.

  • size (Tuple[int, int]) – Image resolution.

Return type:

Dict[str, Any]

Returns:

Processed keypoints for every part.