pose_format.numpy.pose_body module

Classes:

NumPyPoseBody(fps, data, confidence)

Represents pose information leveraging NumPy operations and structures.

class pose_format.numpy.pose_body.NumPyPoseBody(fps, data, confidence)[source]

Bases: PoseBody

Represents pose information leveraging NumPy operations and structures.

  • Inherits from: PoseBody

  • Implements pose info using NumPy operations and structures.

  • Provides method for operations: matrix, multiplication, interpolation and data type conversions

The NumPyPoseBody is an implementation of PoseBody base class. This subclass uses NumPy masked arrays to handle pose data. Makes it suitable for applications where you need NumPy-based operations. The masked arrays allow for efficient handling of missing or invalid pose values

The class also comes with methods to transform, modify, and operate on pose data, including matrix multiplication, interpolation, and conversions to other data types like PyTorch tensors or TensorFlow tensors

Parameters:
  • fps (float) – Frames per second, to represent the temporal aspect of pose data.

  • data (Union[ma.MaskedArray, np.ndarray]) – Pose data either as a masked array or a regular numpy array.

  • confidence (np.ndarray) – confidence array of the pose keypoints.

Methods:

bbox(header)

Computes the bounding boxes for each component based on the pose data.

flatten()

Flattens data and confidence arrays.

flip([axis])

flips pose data across a specified axis

get_points(indexes)

Get points (keypoints) based on given indexes.

interpolate([new_fps, kind])

Interpolates the pose data to match a new frame rate.

matmul(matrix)

Performs matrix multiplication on pose data.

points_perspective()

Transforms pose data to get a perspective based on points.

read_v0_0(header, reader, **unused_kwargs)

Reads pose data from a given buffer reader using a specified data format version (see: docs/specs).

tensorflow()

converts current instance into a TensorflowPoseBody instance

torch()

converts current instance into a TorchPoseBody instance.

write(version, buffer)

Writes pose data to a binary buffer using specified data format version.

zero_filled()

fills missing values with zeros.

Attributes:

mask

Returns mask associated with data.

tensor_reader

bbox(header)[source]

Computes the bounding boxes for each component based on the pose data.

Parameters:

header (PoseHeader) – Pose header information.

Returns:

Pose body data representing bounding boxes.

Return type:

NumPyPoseBody

flatten()[source]

Flattens data and confidence arrays.

method reshapes data and confidence arrays to a two-dimensional array. The flattened array is filtered to remove rows where confidence is zero.

Returns:

flattened and filtered version of the data array.

Return type:

numpy.ndarray

flip(axis=0)[source]

flips pose data across a specified axis

Parameters:

axis (int, optional) – axis along which the pose data should be flipped.

Returns:

flipped pose body data

Return type:

NumPyPoseBody

get_points(indexes)[source]

Get points (keypoints) based on given indexes.

Parameters:

indexes (List[int]) – List of indices representing the keypoints to get.

Returns:

Pose body data containing only a specified points.

Return type:

NumPyPoseBody

interpolate(new_fps=None, kind='cubic')[source]

Interpolates the pose data to match a new frame rate.

Parameters:
  • new_fps (int, optional) – The desired frame rate for interpolation.

  • kind (str, optional) – The type of interpolation. Options include: “linear”, “quadratic”, and “cubic”.

Returns:

Interpolated pose body data.

Return type:

NumPyPoseBody

property mask

Returns mask associated with data.

matmul(matrix)[source]

Performs matrix multiplication on pose data.

Parameters:

matrix (np.ndarray) – matrix to multiply the pose data with

Returns:

transformed pose body data

Return type:

NumPyPoseBody

points_perspective()[source]

Transforms pose data to get a perspective based on points.

Returns:

Transformed pose data

Return type:

ma.MaskedArray

classmethod read_v0_0(header, reader, **unused_kwargs)[source]

Reads pose data from a given buffer reader using a specified data format version (see: docs/specs).

Parameters:
Returns:

Instance of NumPyPoseBody with read pose data.

Return type:

NumPyPoseBody

tensor_reader = "unpack_numpySpecifies the method name for unpacking a numpy array (Value: 'unpack_numpy')."
tensorflow()[source]

converts current instance into a TensorflowPoseBody instance

Returns:

pose body data represented in TensorFlow tensors

Return type:

TensorflowPoseBody

torch()[source]

converts current instance into a TorchPoseBody instance.

Returns:

The pose body data represented in PyTorch tensors.

Return type:

TorchPoseBody

write(version, buffer)[source]

Writes pose data to a binary buffer using specified data format version.

Parameters:
  • version (float) – Version of the data format.

  • buffer (BinaryIO) – The binary buffer to write to.

zero_filled()[source]

fills missing values with zeros.

Returns:

changed pose body data.

Return type:

NumPyPoseBody