Pose¶
Auto-generated documentation for musicalgestures._pose module.
- Mgt-python / Modules / Musicalgestures / Pose
Attributes¶
MEDIAPIPE_POSE_CONNECTIONS- MediaPipe Pose skeleton connections (pairs of landmark indices):[(0, 1), (1, 2), (2, 3), (3, 7), (0, 4), (4, 5)...
download_model¶
Helper function to automatically download model (.caffemodel) files.
pose¶
def pose(
self,
model='body_25',
device='gpu',
threshold=0.1,
downsampling_factor=2,
save_data=True,
data_format='csv',
save_video=True,
target_name_video=None,
target_name_data=None,
overwrite=False,
):
Renders a video with the pose estimation (aka. "keypoint detection" or "skeleton tracking") overlaid on it. Outputs the predictions in a text file containing the normalized x and y coordinates of each keypoint (default format is csv).
Supports two backends:
- MediaPipe (
model='mediapipe'): Uses Google's MediaPipe Pose which detects 33 landmarks entirely on CPU. Requires the optionalmediapipepackage (pip install musicalgestures[pose]). On first use, the model file (~8–28 MB) is downloaded automatically and cached inmusicalgestures/models/. - OpenPose (
model='body_25','coco', or'mpi'): Uses Caffe-based OpenPose models. Model weights (~200 MB) are downloaded on first use.
Arguments¶
modelstr, optional - Pose model to use.'mediapipe'uses MediaPipe Pose (33 landmarks, model auto-downloaded on first use).'body_25'loads the OpenPose BODY_25 model (25 keypoints),'mpi'loads the MPII model (15 keypoints),'coco'loads the COCO model (18 keypoints). Defaults to 'body_25'.devicestr, optional - Sets the backend to use for the neural network ('cpu' or 'gpu'). Ignored whenmodel='mediapipe'(MediaPipe always runs on CPU). Defaults to 'gpu'.thresholdfloat, optional - The normalized confidence threshold that decides whether we keep or discard a predicted point. Discarded points get substituted with (0, 0) in the output data. Defaults to 0.1.downsampling_factorint, optional - Decides how much we downsample the video before we pass it to the neural network. Ignored whenmodel='mediapipe'. Defaults to 2.save_databool, optional - Whether we save the predicted pose data to a file. Defaults to True.data_formatstr, optional - Specifies format of pose-data. Accepted values are 'csv', 'tsv' and 'txt'. For multiple output formats, use list, eg. ['csv', 'txt']. Defaults to 'csv'.save_videobool, optional - Whether we save the video with the estimated pose overlaid on it. Defaults to True.target_name_videostr, optional - Target output name for the video. Defaults to None (which assumes that the input filename with the suffix "_pose" should be used).target_name_datastr, optional - Target output name for the data. Defaults to None (which assumes that the input filename with the suffix "_pose" should be used).overwritebool, optional - Whether to allow overwriting existing files or to automatically increment target filenames to avoid overwriting. Defaults to False.
Returns¶
MgVideo- An MgVideo pointing to the output video.