pose_format package
Here’s a breakdown of the main subpackages:
NumPy package e.g
pose_format.numpy:This subpackage offers an integration with the popular NumPy library and helps with numerical computations on pose data.
pose_format.numpy.pose_bodymodule and subpackages:Provides tools to handle body data in context of pose with NumPy.
TensorFlow package e.g
pose_format.tensorflow:Provides integration with TensorFlow library, therefore this subpackage offers operations on pose data in TensorFlow contexts.
pose_format.tensorflow.pose_body:Main module for handling body data within TensorFlow.
pose_format.tensorflow.pose_body_test:Test module to ensure reliability of pose body operations in TensorFlow.
pose_format.tensorflow.pose_representationandpose_format.tensorflow.pose_representation_test:These modules help the representation of poses in TensorFlow.
Testing package e.g
pose_format.testing:This subpackage provides test cases to ensure reliability of entire
pose_formatpackage.Third-Party package e.g
pose_format.third_party:
Contains modules and utilities that integrate third-party tools or libraries with pose format
PyTorch package e.g
pose_format.torch:This subpackage provides modules to manage and manipulate pose data in a PyTorch context
-
Module for handling pose body data within PyTorch.
pose_format.torch.pose_representation:Helps representing pose data in PyTorch.
-
Utils package e.g
pose_format.utils:This subpackage consists of various modules to help operations related to pose data.
Subpackages:
- pose_format.numpy package
- pose_format.numpy.representation package
- pose_format.numpy.pose_body module
NumPyPoseBodyNumPyPoseBody.bbox()NumPyPoseBody.flatten()NumPyPoseBody.flip()NumPyPoseBody.get_points()NumPyPoseBody.interpolate()NumPyPoseBody.maskNumPyPoseBody.matmul()NumPyPoseBody.points_perspective()NumPyPoseBody.read_v0_0()NumPyPoseBody.tensor_readerNumPyPoseBody.tensorflow()NumPyPoseBody.torch()NumPyPoseBody.write()NumPyPoseBody.zero_filled()
- pose_format.tensorflow package
- pose_format.tensorflow.masked package
- pose_format.tensorflow.masked.tensor module
MaskedTensorMaskedTensor.arithmetic()MaskedTensor.div()MaskedTensor.fix_nan()MaskedTensor.float()MaskedTensor.gather()MaskedTensor.matmul()MaskedTensor.mean()MaskedTensor.permute()MaskedTensor.rename()MaskedTensor.reshape()MaskedTensor.size()MaskedTensor.split()MaskedTensor.sqrt()MaskedTensor.square()MaskedTensor.squeeze()MaskedTensor.std()MaskedTensor.sum()MaskedTensor.transpose()MaskedTensor.variance()MaskedTensor.zero_filled()
- pose_format.tensorflow.masked.tensor_graph_mode_test module
- pose_format.tensorflow.masked.tensor_test module
- pose_format.tensorflow.masked.tensorflow module
- pose_format.tensorflow.masked.tensorflow_test module
TestMaskedTensorflowTestMaskedTensorflow.test_cat()TestMaskedTensorflow.test_not_implemented_method()TestMaskedTensorflow.test_stack()TestMaskedTensorflow.test_zeros_mask_value()TestMaskedTensorflow.test_zeros_tensor_shape()TestMaskedTensorflow.test_zeros_tensor_type_bool()TestMaskedTensorflow.test_zeros_tensor_type_float()TestMaskedTensorflow.test_zeros_tensor_value()
- pose_format.tensorflow.masked.tensor module
- pose_format.tensorflow.representation package
- pose_format.tensorflow.representation.angle module
- pose_format.tensorflow.representation.angle_test module
- pose_format.tensorflow.representation.distance module
- pose_format.tensorflow.representation.distance_test module
- pose_format.tensorflow.representation.inner_angle module
- pose_format.tensorflow.representation.inner_angle_test module
- pose_format.tensorflow.representation.point_line_distance module
- pose_format.tensorflow.representation.point_line_distance_test module
- pose_format.tensorflow.pose_body module
TensorflowPoseBodyTensorflowPoseBody.as_tfrecord()TensorflowPoseBody.frame_dropout_given_percent()TensorflowPoseBody.frame_dropout_normal()TensorflowPoseBody.frame_dropout_uniform()TensorflowPoseBody.from_tfrecord()TensorflowPoseBody.get_points()TensorflowPoseBody.matmul()TensorflowPoseBody.points_perspective()TensorflowPoseBody.select_frames()TensorflowPoseBody.tensor_readerTensorflowPoseBody.zero_filled()
- pose_format.tensorflow.pose_body_test module
- pose_format.tensorflow.pose_representation module
- pose_format.tensorflow.pose_representation_test module
- pose_format.tensorflow.masked package
- pose_format.testing package
- pose_format.third_party package
- pose_format.torch package
- pose_format.torch.masked package
- pose_format.torch.masked.tensor module
MaskedTensorMaskedTensor.arithmetic()MaskedTensor.cuda()MaskedTensor.div()MaskedTensor.fix_nan()MaskedTensor.matmul()MaskedTensor.permute()MaskedTensor.pow_()MaskedTensor.rename()MaskedTensor.reshape()MaskedTensor.size()MaskedTensor.split()MaskedTensor.squeeze()MaskedTensor.sum()MaskedTensor.to()MaskedTensor.transpose()MaskedTensor.zero_filled()
- pose_format.torch.masked.torch module
- pose_format.torch.masked.torch_test module
TestMaskedTorchTestMaskedTorch.test_cat()TestMaskedTorch.test_not_implemented_method()TestMaskedTorch.test_stack()TestMaskedTorch.test_zeros_mask_value()TestMaskedTorch.test_zeros_tensor_shape()TestMaskedTorch.test_zeros_tensor_type_bool()TestMaskedTorch.test_zeros_tensor_type_float()TestMaskedTorch.test_zeros_tensor_value()
- pose_format.torch.masked.tensor module
MaskedTensorMaskedTensor.arithmetic()MaskedTensor.cuda()MaskedTensor.div()MaskedTensor.fix_nan()MaskedTensor.matmul()MaskedTensor.permute()MaskedTensor.pow_()MaskedTensor.rename()MaskedTensor.reshape()MaskedTensor.size()MaskedTensor.split()MaskedTensor.squeeze()MaskedTensor.sum()MaskedTensor.to()MaskedTensor.transpose()MaskedTensor.zero_filled()
- pose_format.torch.masked.torch module
- pose_format.torch.masked.torch_test module
TestMaskedTorchTestMaskedTorch.test_cat()TestMaskedTorch.test_not_implemented_method()TestMaskedTorch.test_stack()TestMaskedTorch.test_zeros_mask_value()TestMaskedTorch.test_zeros_tensor_shape()TestMaskedTorch.test_zeros_tensor_type_bool()TestMaskedTorch.test_zeros_tensor_type_float()TestMaskedTorch.test_zeros_tensor_value()
- pose_format.torch.masked.tensor module
- pose_format.torch.representation package
- pose_format.torch.representation.angle module
- pose_format.torch.representation.angle_test module
- pose_format.torch.representation.distance module
- pose_format.torch.representation.distance_test module
- pose_format.torch.representation.inner_angle module
- pose_format.torch.representation.inner_angle_test module
- pose_format.torch.representation.point_line_distance module
- pose_format.torch.representation.point_line_distance_test module
- pose_format.torch.representation.points module
- Submodules
- pose_format.torch.masked package
- pose_format.utils package
- pose_format.utils.fast_math module
- pose_format.utils.normalization_3d module
- pose_format.utils.openpose module
- pose_format.utils.openpose_135 module
- pose_format.utils.openpose_test module
TestLoadOpenposeTestLoadOpenpose.test_load_openpose_data_shape()TestLoadOpenpose.test_load_openpose_data_shape_missing_frames()TestLoadOpenpose.test_load_openpose_extracts_correct_number_of_people()TestLoadOpenpose.test_load_openpose_fixed_num_frames()TestLoadOpenpose.test_load_openpose_fixed_num_frames_and_missing_frames()TestLoadOpenpose.test_load_openpose_returns_pose_object()
TestLoadOpenposeDirectoryTestLoadOpenposeDirectory.test_get_frame_id_no_prefix()TestLoadOpenposeDirectory.test_get_frame_id_nonzero()TestLoadOpenposeDirectory.test_get_frame_id_several_digits()TestLoadOpenposeDirectory.test_get_frame_id_zero()TestLoadOpenposeDirectory.test_load_openpose_directory_data_shape()TestLoadOpenposeDirectory.test_load_openpose_directory_data_shape_add_empty_keys()TestLoadOpenposeDirectory.test_load_openpose_directory_data_shape_missing_frames()TestLoadOpenposeDirectory.test_load_openpose_directory_data_shape_no_file_prefix()TestLoadOpenposeDirectory.test_load_openpose_directory_extracts_correct_number_of_people()TestLoadOpenposeDirectory.test_load_openpose_directory_returns_pose_object()
TestOpenposeComponentsTestOpenposeComponents.test_openpose_components_names()TestOpenposeComponents.test_openpose_components_total_points()TestOpenposeComponents.test_openpose_num_points_per_component_face()TestOpenposeComponents.test_openpose_num_points_per_component_hand_left()TestOpenposeComponents.test_openpose_num_points_per_component_hand_right()TestOpenposeComponents.test_openpose_num_points_per_component_pose()
- pose_format.utils.optical_flow module
- pose_format.utils.reader module
- pose_format.utils.reader_test module
TestBufferReaderTestBufferReader.test_advance()TestBufferReader.test_bytes_left()TestBufferReader.test_unpack()TestBufferReader.test_unpack_f()TestBufferReader.test_unpack_numpy()TestBufferReader.test_unpack_numpy_writeable()TestBufferReader.test_unpack_str()TestBufferReader.test_unpack_tensorflow()TestBufferReader.test_unpack_torch()
- pose_format.utils.siren module
- pose_format.utils.pose_converter module
- pose_format.utils.holistic module
Submodules
pose_format.pose module
Classes:
|
File IO for '.pose' file format, including the header and body. |
- class pose_format.pose.Pose(header, body)[source]
Bases:
objectFile IO for ‘.pose’ file format, including the header and body.
- Parameters:
header (PoseHeader) – Header information for the pose.
body (PoseBody) – Body data for the pose.
Methods:
bbox()Calculates bounding box for Pose.
focus()Gets the pose to start at (0,0) and have dimensions as big as needed
frame_dropout_normal([dropout_mean, dropout_std])Normal frame dropout on Pose.
frame_dropout_uniform([dropout_min, dropout_max])Perform uniform frame dropout on Pose
get_components(components[, points])get pose components based on criteria.
normalize(info[, scale_factor])Normalize the points to a fixed distance between two particular points.
normalize_distribution([mu, std, axis])Normalize points distribution.
read(buffer[, pose_body])Read Pose object from buffer.
unnormalize_distribution(mu, std)Given mean, standard deviationn unnormalization applied to the pose points distribution.
write(buffer)Write Pose object to buffer.
Attributes:
A set of method names which define actions that can be applied to the pose data.
- bbox()[source]
Calculates bounding box for Pose.
- Returns:
Pose object representing bounding box (bbox).
- Return type:
- frame_dropout_normal(dropout_mean=0.5, dropout_std=0.1)[source]
Normal frame dropout on Pose.
- Parameters:
dropout_mean (float, optional) – Mean value for dropout. Defaults to 0.5.
dropout_std (float, optional) – Standard deviation for dropout. Defaults to 0.1.
- Returns:
a tuple with Pose of dropped frames and a list of selected indexes.
- Return type:
tuple
- frame_dropout_uniform(dropout_min=0.2, dropout_max=1.0)[source]
Perform uniform frame dropout on Pose
- Parameters:
dropout_min (float, optional) – Minimum dropout value. Defaults to 0.2.
dropout_max (float, optional) – Maximum dropout value. Defaults to 1.0.
- Returns:
a tuple containing Pose with dropped frames and a list of selected indexes.
- Return type:
tuple
- get_components(components, points=None)[source]
get pose components based on criteria.
- Parameters:
components (List[str]) – List of component names to get.
points (Dict[str, List[str]], optional) – Mapping of component names to lists of point names to get.
- Returns:
Pose object containing new components
- Return type:
- normalize(info, scale_factor=1)[source]
Normalize the points to a fixed distance between two particular points.
- Parameters:
info (PoseNormalizationInfo) – Information for normalization.
scale_factor (float, optional) – Scaling factor. Defaults to 1.
- Returns:
The normalized Pose object.
- Return type:
- normalize_distribution(mu=None, std=None, axis=(0, 1))[source]
Normalize points distribution.
- Parameters:
mu (np.ndarray, optional) – Mean values for normalization. If None, it will be computed.
std (np.ndarray, optional) – Standard deviation values for normalization. If None, it will be computed.
axis (tuple of int, optional) – Axes for mean and std computation. Defaults to (0, 1).
- Returns:
Calculated mean and standard deviation.
- Return type:
tuple of np.ndarray
- pass_through_methods = {'augment2d', 'flip', 'interpolate', 'slice_step', 'tensorflow', 'torch'}
A set of method names which define actions that can be applied to the pose data.
- Parameters:
augment2d (str) – Represents a method to augment 2D points.
flip (str) – Represents a method to flip the pose on an axis.
interpolate (str) – Represents a method to interpolate missing pose points.
torch (str) – Represents a method to convert the body data to torch format.
tensorflow (str) – Represents a method to convert the body data to TensorFlow format.
slice_step (str) – Represents a method to step through the data.
- static read(buffer, pose_body=<class 'pose_format.numpy.pose_body.NumPyPoseBody'>, **kwargs)[source]
Read Pose object from buffer.
pose_format.pose_body module
Classes:
|
Class for body data of a pose. |
- class pose_format.pose_body.PoseBody(fps, data, confidence)[source]
Bases:
objectClass for body data of a pose.
- Parameters:
fps (float) – Frames per second.
data – Data in the format (Frames, People, Points, Dims) e.g., (93, 1, 137, 2).
confidence – Confidence data in the format (Frames, People, Points) e.g., (93, 1, 137).
Methods:
augment2d([rotation_std, shear_std, scale_std])Augment 2D data with given standard deviations.
bbox(header)For computing bounding box of PoseBody.
flatten()Converts data from the (Frames, People, Points, Dims) masked representation to an array of points.
frame_dropout_given_percent(dropout_percent)Drop of frames based on given dropout percentage.
frame_dropout_normal([dropout_mean, dropout_std])drop frames depending on normal distribution with given mean and standard deviation.
frame_dropout_uniform([dropout_min, dropout_max])Randomly drops frames depending on a uniform distribution - given minimum and maximum percentages.
get_points(indexes)Get points from PoseBody.
matmul(matrix)Multiplies PoseBody data with a numpy.ndarray matrix.
numpy()Convert the current PoseBody representation to NumpyPoseBody.
Give points in PoseBody as a perspective view.
read(header, reader, **kwargs)Reads pose data a buffer (BufferReader) based on the header's version.
read_v0_0(header, reader, **unused_kwargs)reads version 0.0 pose data.
read_v0_1(header, reader[, start_frame, ...])Reads pose data for version 0.1 from a buffer.
read_v0_1_frames(frames, shape, reader[, ...])Reads frame data for version 0.1 from a buffer.
select_frames(frame_indexes)Selects specific frames from PoseBody object.
slice_step(by)Slices data by skipping rows.
Converts current PoseBody representation to TensorflowPoseBody.
torch()Converts current PoseBody to TorchPoseBody.
write(version, buffer)Writes data to a file based on version of spec: in docs/spec.
Creates a new PoseBody instance with data replaced by zeros.
Attributes:
- augment2d(rotation_std=0.2, shear_std=0.2, scale_std=0.2)[source]
Augment 2D data with given standard deviations.
- Parameters:
rotation_std (float, optional) – Rotation in radians. Default is 0.2.
shear_std (float, optional) – Shear X in percent. Default is 0.2.
scale_std (float, optional) – Scale X in percent. Default is 0.2.
- Returns:
Augmented PoseBody instance.
- Return type:
Note
The method modifies the PoseBody based on shear, rotation, and scaling.
shear_std based on https://en.wikipedia.org/wiki/Shear_matrix
rotation_std based on https://en.wikipedia.org/wiki/Rotation_matrix
scale_std based on https://en.wikipedia.org/wiki/Scaling_(geometry)
- bbox(header)[source]
For computing bounding box of PoseBody.
- Parameters:
header (PoseHeader) – Header containing the version of the pose data.
- Returns:
PoseBody instance with bounding box.
- Return type:
- Raises:
NotImplementedError – If the
bboxis not implemented in class.
- flatten()[source]
Converts data from the (Frames, People, Points, Dims) masked representation to an array of points.
Every item in the result array contains the following dimensions: 0. Time in milliseconds 1. Person ID 2. Point ID 3. X dimension 4. Y dimension 5. Z dimension (if exists) 6. Pose estimation confidence
- Returns:
Array of points with detailed dimensions.
- Return type:
np.ndarray
- Raises:
NotImplementedError – If the method is not implemented for the specific class.
- frame_dropout_given_percent(dropout_percent)[source]
Drop of frames based on given dropout percentage.
- Parameters:
dropout_percent (float) – Percentage of frames to drop. Between 0 and 1 (e.g., 0.2 means drop 20% of the frames).
- Returns:
New PoseBody object with the gotten frames.
List of frame indexes.
- Return type:
Tuple[PoseBody, List[int]]
Note
Actual number of dropped frames might be slightly different due to rounding!
- frame_dropout_normal(dropout_mean=0.5, dropout_std=0.1)[source]
drop frames depending on normal distribution with given mean and standard deviation.
- Parameters:
dropout_mean (float, optional) – Mean percentage of frames to drop. Default is 0.5.
dropout_std (float, optional) – Standard deviation of percentage of frames to drop. Default is 0.1.
- Returns:
New PoseBody object with dropped frames.
List of retrieved frame indexes.
- Return type:
Tuple[PoseBody, List[int]]
- frame_dropout_uniform(dropout_min=0.2, dropout_max=1.0)[source]
Randomly drops frames depending on a uniform distribution - given minimum and maximum percentages.
- Parameters:
dropout_min (float, optional) – Minimum percentage of frames to drop. Default is 0.2.
dropout_max (float, optional) – Maximum percentage of frames to drop. Default is 1.0.
- Returns:
New PoseBody object with dropped frames.
List of frame indexes that were retained.
- Return type:
Tuple[PoseBody, List[int]]
- get_points(indexes)[source]
Get points from PoseBody.
- Parameters:
indexes (List[int]) – List of point indices to get from PoseBody.
- Returns:
PoseBody instance containing only choosen points.
- Return type:
- Raises:
NotImplementedError – If the
get_pointsis not implemented in class.
- matmul(matrix)[source]
Multiplies PoseBody data with a numpy.ndarray matrix.
- Parameters:
matrix (np.ndarray) – The matrix to multiply the PoseBody data with.
- Returns:
PoseBody instance with data multiplied by a numpy array.
- Return type:
- Raises:
NotImplementedError – If the matmul is not implemented in class.
- numpy()[source]
Convert the current PoseBody representation to NumpyPoseBody.
- Returns:
The converted PoseBody object.
- Return type:
NumpyPoseBody
- Raises:
NotImplementedError – If numpy is not implemented.
- points_perspective()[source]
Give points in PoseBody as a perspective view.
- Returns:
PoseBody instance with points adjusted for perspective.
- Return type:
- Raises:
NotImplementedError – If the method is not implemented for the specific class.
- classmethod read(header, reader, **kwargs)[source]
Reads pose data a buffer (BufferReader) based on the header’s version.
- Parameters:
header (PoseHeader) – Header containing the version of its pose data.
reader (BufferReader) – Buffer from which to read the pose data.
**kwargs (dict) – Additional parameters for reading specific versions.
- Returns:
PoseBody object initialized with the read data.
- Return type:
- Raises:
NotImplementedError – If header’s version is not supported / unknown.
- classmethod read_v0_0(header, reader, **unused_kwargs)[source]
reads version 0.0 pose data.
- Parameters:
header (PoseHeader) – Header containing the version of the pose data.
reader (BufferReader) – Buffer from which to read the pose data.
unused_kwargs (dict) – Unused additional parameters for this version.
- Raises:
NotImplementedError – method for this version is not implemented.
- classmethod read_v0_1(header, reader, start_frame=None, end_frame=None, **unused_kwargs)[source]
Reads pose data for version 0.1 from a buffer.
- Parameters:
header (PoseHeader) – Header containing the version of the pose data.
reader (BufferReader) – Buffer from which to read the pose data.
start_frame (int, optional) – Index of the first frame to read. Default is None.
end_frame (int, optional) – Index of the last frame to read. Default is None.
**unused_kwargs (dict) – Unused additional parameters for this version.
- Returns:
PoseBody object initialized with the read data for version 0.1.
- Return type:
- classmethod read_v0_1_frames(frames, shape, reader, start_frame=None, end_frame=None)[source]
Reads frame data for version 0.1 from a buffer.
- Parameters:
frames (int) – Number of frames in the pose data.
shape (List[int]) – Shape of the pose data.
reader (BufferReader) – Buffer from which to read the pose data.
start_frame (int, optional) – Index of the first frame to read. Default is None.
end_frame (int, optional) – Index of the last frame to read. Default is None.
- Returns:
Array containing the pose data for the specified frames.
- Return type:
ndarray
- Raises:
ValueError – If start_frame is greater than number of frames.
- select_frames(frame_indexes)[source]
Selects specific frames from PoseBody object.
- Parameters:
frame_indexes (List[int]) – List of frame indexes to select.
- Returns:
PoseBody object containing only the selected frames.
- Return type:
- Raises:
IndexError – If any of the specified frame indices are out of the valid range for the current PoseBody data.
- slice_step(by)[source]
Slices data by skipping rows. This affects the fps (frames per seconds).
- Parameters:
by (int) – Take one row every “by” rows.
- Returns:
PoseBody instance with sliced data.
- Return type:
- tensor_reader = 'ABSTRACT-DO-NOT-USE'
- tensorflow()[source]
Converts current PoseBody representation to TensorflowPoseBody.
- Returns:
Converted PoseBody object.
- Return type:
- Raises:
NotImplementedError – If tensorflow is not implemented.
- torch()[source]
Converts current PoseBody to TorchPoseBody.
- Returns:
The converted PoseBody object.
- Return type:
- Raises:
NotImplementedError – If toch is not implemented.
pose_format.pose_header module
Classes:
|
Main header for a pose. |
|
Class for pose header component |
|
Represents width, height, and depth dimensions for a pose header. |
|
This class represents is used for normalization info for pose. |
- class pose_format.pose_header.PoseHeader(version, dimensions, components, is_bbox=False)[source]
Bases:
objectMain header for a pose.
- Parameters:
version (float) – Version of the pose header.
dimensions (PoseHeaderDimensions) – Dimensions of the pose header.
components (List[PoseHeaderComponent]) – List of pose header components.
is_bbox (bool, optional) – If bounding box needed. Default is False.
Note
Use the
readmethod to generate an instance from a BufferReader.total_pointsmethod returns the total number of points across all components.Convert the header to bounding boxes using the
bboxmethod.
Examples
>>> header = PoseHeader(1.0, PoseHeaderDimensions(10, 20, 5), [PoseHeaderComponent(...)], is_bbox=True) >>> print(header.is_bbox) True
Methods:
bbox()Converts header to bounding boxes (bbox).
normalization_info(p1, p2[, p3])Normalizates info for given points.
read(reader)Reads pose header data from a reader (BufferReader).
Returns number of points
write(buffer)Writes the pose header to a buffer (BinaryIO).
- bbox()[source]
Converts header to bounding boxes (bbox).
- Returns:
PoseHeader with bounding box information.
- Return type:
- normalization_info(p1, p2, p3=None)[source]
Normalizates info for given points.
- Parameters:
p1 (Tuple[str, str]) – First point.
p2 (Tuple[str, str]) – Second point.
p3 (Tuple[str, str], optional) – Third point.
- Returns:
Normalization information for the points.
- Return type:
- static read(reader)[source]
Reads pose header data from a reader (BufferReader).
- Parameters:
reader (BufferReader) – Reader object.
- Returns:
An instance of PoseHeader.
- Return type:
- class pose_format.pose_header.PoseHeaderComponent(name, points, limbs, colors, point_format)[source]
Bases:
objectClass for pose header component
- Parameters:
name (str) – Name of the pose header component
points (List[str]) – List of point names.
limbs (List[Tuple[int, int]]) – List of limb indices.
colors (List[Tuple[int, int, int]]) – List of RGB colors for each limb.
point_format (str) – Format for the points.
Note
Limbs and colors should have the same length. The index in the limbs list corresponds to a color in the colors list.
Methods:
Get relative limbs mapping.
read(version, reader)Reads pose header dimensions from reader (BufferReader).
write(buffer)Writes pose header dimensions to a buffer (BinaryIO).
- get_relative_limbs()[source]
Get relative limbs mapping.
Constructs a mapping from the second point in each limb tuple to its index in the limbs list. Then, it attempts to map each first point in the limbs tuple to its corresponding index.
- Returns:
List of relative limb indices or None if the limb does not have a relative mapping.
- Return type:
list
Note
returned list is based on the
self.limbsof the instance, its structure is expected to be a list of tuples, where each tuple represents a limb with two points.
- static read(version, reader)[source]
Reads pose header dimensions from reader (BufferReader).
- Parameters:
version (float) – Version information.
reader (BufferReader) – Reader object.
- Returns:
instance of PoseHeaderDimensions.
- Return type:
- class pose_format.pose_header.PoseHeaderDimensions(width, height, depth=0, *args)[source]
Bases:
objectRepresents width, height, and depth dimensions for a pose header.
- Parameters:
width (int) – Width of the pose.
height (int) – Height of the pose.
depth (int) – Depth of the pose. Defaults to 0.
- Raises:
ValueError – If any dimension value is out of bounds (0 to 65535).
Examples
>>> dimensions = PoseHeaderDimensions(10, 20, 5) >>> print(dimensions.width) 10
Methods:
read(version, reader)Reads and returns a PoseHeaderDimensions object from a buffer reader.
write(buffer)Writes dimensions to a buffer.
- static read(version, reader)[source]
Reads and returns a PoseHeaderDimensions object from a buffer reader.
- Parameters:
version (float) – Version of the data being read.
reader (BufferReader) – The reader
- Returns:
Instance of PoseHeaderDimensions with its read dimensions (width, height, depth).
- Return type:
pose_format.pose_representation module
Classes:
|
Represents a pose using various representation modules. |
- class pose_format.pose_representation.PoseRepresentation(header, rep_modules1=[], rep_modules2=[], rep_modules3=[])[source]
Bases:
objectRepresents a pose using various representation modules.
- Parameters:
header (PoseHeader) – Header information about the pose.
rep_modules1 (List, optional) – List of modules that use a point-based representation. Defaults to an empty list.
rep_modules2 (List, optional) – List of modules that use a limb-based representation. Defaults to an empty list.
rep_modules3 (List, optional) – List of modules that use a triangle-based representation. Defaults to an empty list.
- input_size
Combined point count across all components of the header.
- Type:
int
- rep_modules1_size
The size represented by the point-based modules.
- Type:
int
- rep_modules2_size
The size represented by the limb-based modules.
- Type:
int
- rep_modules3_size
The size represented by the triangle-based modules.
- Type:
int
- output_size
The overall size of the output representation.
- Type:
int
Methods:
Calculate total size of output representation, based on active modules
Get points that define limbs
get_points(tensor, points)get points from a given tensor
Get points that make up triangles.
group_embeds(embeds)Groups given embeddings into a desired format.
permute(src, shape)Permutes given tensor according to shape.
- calc_output_size()[source]
Calculate total size of output representation, based on active modules
- Returns:
Total size of the module representation.
- Return type:
int
- get_limbs_points()[source]
Get points that define limbs
- Returns:
Two lists containing points that define the start and end of each limb.
- Return type:
Tuple[List, List]
- get_points(tensor, points)[source]
get points from a given tensor
- Parameters:
tensor (torch.Tensor) – Tensor from which you need the points.
points (List[int]) – Indices of points that need to be extracted.
- Returns:
Gotten points from tensor.
- Return type:
torch.Tensor
- get_triangles_points()[source]
Get points that make up triangles.
- Returns:
Three lists which have points that define each corner of the triangles.
- Return type:
Tuple[List, List, List]
- group_embeds(embeds)[source]
Groups given embeddings into a desired format. Must be implemented by subclasses.
- Parameters:
embeds (List) – List of tensor embeddings, tensor size: (embed_size, Batch, Len).
- Raises:
NotImplementedError – If the method is not implemented by subclasses.
- Return type:
Size (Batch, Len, embed_size)
pose_format.pose_test module
pose_format.pose_visualizer module
Classes:
|
This class draws all frames as grayscale, without opacity based on confidence values. |
|
A class for visualizing Pose objects using OpenCV. |
- class pose_format.pose_visualizer.FastAndUglyPoseVisualizer(pose, thickness=None)[source]
Bases:
PoseVisualizerThis class draws all frames as grayscale, without opacity based on confidence values. It is a faster and less detailed “ugly” class for visualizing Pose objects using OpenCV.
Inherites from
PoseViszaizer
Methods:
draw([background_color, foreground_color])draws the pose on plain background using a foreground (pose) color.
- Parameters:
pose (Pose) –
- draw(background_color=0, foreground_color=255)[source]
draws the pose on plain background using a foreground (pose) color.
- Parameters:
background_color (int) – Grayscale value for background color.
foreground_color (int) – Grayscale value for the pose color.
- Yields:
np.ndarray – frames with drawn pose
- class pose_format.pose_visualizer.PoseVisualizer(pose, thickness=None)[source]
Bases:
objectA class for visualizing Pose objects using OpenCV.
- Parameters:
pose (Pose) – The Pose object to visualize.
thickness (int or None) – Thickness for drawing. If not provided, it is estimated based on image size.
pose_fps (float) – Frame rate of the Pose data.
*cv2 (module) – OpenCV Python binding.
Methods:
draw([background_color, max_frames])draws pose on plain background using the specified color - for a number of frames.
draw_on_video(background_video[, ...])Draw pose on a background video.
save_frame(f_name, frame)Save a single pose frame as im.
save_gif(f_name, frames)Save pose frames as GIF.
save_video(f_name, frames[, custom_ffmpeg])Save pose frames as a video.
- draw(background_color=(255, 255, 255), max_frames=None)[source]
draws pose on plain background using the specified color - for a number of frames.
- Parameters:
background_color (Tuple[int, int, int], optional) – RGB value for background color, default is white (255, 255, 255).
max_frames (int, optional) – Maximum number of frames to process, if it is None, it processes all frames.
- Yields:
np.ndarray – Frames with the pose data drawn on a custom background color.
- draw_on_video(background_video, max_frames=None, blur=False)[source]
Draw pose on a background video.
- Parameters:
background_video (str or iterable) – Path to video file or iterable of video frames.
max_frames (int, optional) – Maximum number of frames to process. If None, it will be processing all frames.
blur (bool, optional) – If True, applies a blur effect to the video.
- Yields:
np.ndarray – Frames with overlaid pose data.
- save_frame(f_name, frame)[source]
Save a single pose frame as im.
- Parameters:
f_name (str) – filensmr where the frame will be saved.
frame (np.ndarray) – Pose frame to be saved
- Return type:
None
- save_gif(f_name, frames)[source]
Save pose frames as GIF.
- Parameters:
f_name (str) – filename to save GIF to.
frames (Iterable[np.ndarray]) – Series of pose frames to be included in GIF.
- Return type:
None
- Raises:
ImportError – If Pillow is not installed.
- save_video(f_name, frames, custom_ffmpeg=None)[source]
Save pose frames as a video.
- Parameters:
f_name (str) – Filename to which the generated video is saved to .
frames (Iterable[np.ndarray]) – Iterable of pose frames include in the video.
custom_ffmpeg (optional) – Custom ffmpeg parameters for the “video writing”.
- Return type:
None
- Raises:
ImportError – If vidgear is not installed.