pose_format.utils.openpose module
Functions:
|
This "lambda" function creates a PoseHeaderComponent using 'name' and a constants for points, limbs, colors, and format. |
|
Parses a filename to find the ID of a frame. |
|
Convert limb names to indices based on a list of points. |
|
Load a pose directory where each frame's pose data is stored in a separate file following a specific naming scheme. |
|
Loads a dictionary of OpenPose frames into a Pose object. |
|
Loads pose data from a directory containing OpenPose files and return a |
- pose_format.utils.openpose.OpenPose_Hand_Component(name)
This “lambda” function creates a PoseHeaderComponent using ‘name’ and a constants for points, limbs, colors, and format.
- pose_format.utils.openpose.get_frame_id(filename, pattern)[source]
Parses a filename to find the ID of a frame. Example file name for frame with ID 17:
CAM2_000000000017_keypoints.json.- Parameters:
filename (str) – Name of the openpose frame file.
pattern (str, optional) – Regex pattern to extract frame ID, default is OPENPOSE_FRAME_PATTERN.
- Returns:
Frame ID as an integer.
- Return type:
int
- pose_format.utils.openpose.limbs_index(limbs, points)[source]
Convert limb names to indices based on a list of points.
- Parameters:
limbs (list of tuple of str) – limbs defined by point names
points (list of str (List[str])) – list of point names
- Returns:
List of limbs defined by point indices
- Return type:
list of tuple of int
- pose_format.utils.openpose.load_frames_directory_dict(directory, pattern)[source]
Load a pose directory where each frame’s pose data is stored in a separate file following a specific naming scheme. Filenames must adhere to the format:
[ARBITRARY CHARACTERS]_[FRAME_ID]_keypoints.json. Example: For a frame with ID 17, the filename would beCAM2_000000000017_keypoints.json.- Parameters:
directory (str) – Path to the folder containing pose files.
pattern (str, optional) – Regular expression pattern to identify and parse frame filenames. The default pattern expects filenames of the form
[ARBITRARY CHARACTERS]_[FRAME_ID]_keypoints.json.
- Returns:
Dictionary where keys are frame IDs (int) and values are the corresponding frames (dict).
- Return type:
OpenPoseFrames
Examples
>>> frames = load_frames_directory_dict("path/to/frames") >>> print(frames[17]) {...} # content of CAM2_000000000017_keypoints.json
- pose_format.utils.openpose.load_openpose(frames, fps=24, width=1000, height=1000, depth=0, num_frames=None)[source]
Loads a dictionary of OpenPose frames into a Pose object.
- Parameters:
frames (dict) – Dictionary where keys are frame IDs, and values are individual frames. Each individual frame is also a dictionary.
fps (float, optional) – Framerate, default is 24.
width (int, optional) – Width of pose space, default is 1000.
height (int, optional) – Height of pose space, default is 1000.
depth (int, optional) – Depth of pose space, default is 0.
num_frames (int, optional) – Number of frames when it’s known and cannot be derived from OpenPose files. That is the case if the last frame(s) of a video are missing from the OpenPose output. Default is None.
- Returns:
Pose object with a header specific to OpenPose and a body that contains a single array.
- Return type:
- pose_format.utils.openpose.load_openpose_directory(directory, fps=24, width=1000, height=1000, depth=0, num_frames=None)[source]
Loads pose data from a directory containing OpenPose files and return a
Poseobject.- Parameters:
directory (str) – Path to the folder that contains pose files.
fps (float, optional) – Framerate. Default is 24.
width (int, optional) – Width of pose space. Default 1000.
height (int, optional) – Height of pose space, default; 1000.
depth (int, optional) – Depth of pose space, default; 0.
num_frames (int, optional) – Number of frames when known and cannot be derived from OpenPose files. This can be the case if the last frame(s) of a video are missing from the OpenPose output. Default is None.
- Returns:
Pose object with a header specific to OpenPose and a body containing a single array.
- Return type:
Examples
>>> pose = load_openpose_directory("path/to/frames") >>> print(pose.header) PoseHeader(...)