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: