pose_format.pose_header module

Classes:

PoseHeader(version, dimensions, components)

Main header for a pose.

PoseHeaderComponent(name, points, limbs, ...)

Class for pose header component

PoseHeaderDimensions(width, height[, depth])

Represents width, height, and depth dimensions for a pose header.

PoseNormalizationInfo(p1, p2[, p3])

This class represents is used for normalization info for pose.

class pose_format.pose_header.PoseHeader(version, dimensions, components, is_bbox=False)[source]

Bases: object

Main 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 read method to generate an instance from a BufferReader.

  • total_points method returns the total number of points across all components.

  • Convert the header to bounding boxes using the bbox method.

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).

total_points()

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:

PoseHeader

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:

PoseNormalizationInfo

static read(reader)[source]

Reads pose header data from a reader (BufferReader).

Parameters:

reader (BufferReader) – Reader object.

Returns:

An instance of PoseHeader.

Return type:

PoseHeader

total_points()[source]

Returns number of points

Returns:

Total number of points.

Return type:

int

write(buffer)[source]

Writes the pose header to a buffer (BinaryIO).

Parameters:

buffer (BinaryIO) – Buffer to write data into.

class pose_format.pose_header.PoseHeaderComponent(name, points, limbs, colors, point_format)[source]

Bases: object

Class 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()

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.limbs of 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:

PoseHeaderDimensions

write(buffer)[source]

Writes pose header dimensions to a buffer (BinaryIO).

Parameters:

buffer (BinaryIO) – Buffer to write data info.

Raises:

ValueError – If dimension value is out of bounds.

class pose_format.pose_header.PoseHeaderDimensions(width, height, depth=0, *args)[source]

Bases: object

Represents 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:

PoseHeaderDimensions

write(buffer)[source]

Writes dimensions to a buffer.

Parameters:

buffer (BinaryIO) – Buffer to which dimensions (width, height, depth) will be written.

Raises:

ValueError – If any dimension value is out of bounds (0 to 65535).

class pose_format.pose_header.PoseNormalizationInfo(p1, p2, p3=None)[source]

Bases: object

This class represents is used for normalization info for pose.

Parameters:
  • p1 (int) – First pose value

  • p2 (int) – Second pose value.

  • p3 (int, optional) – Third pose value. Defaults to None.