pose_format.pose_body module

Classes:

PoseBody(fps, data, confidence)

Class for body data of a pose.

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

Bases: object

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

points_perspective()

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.

tensorflow()

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.

zero_filled()

Creates a new PoseBody instance with data replaced by zeros.

Attributes:

tensor_reader

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:

PoseBody

Note

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:

PoseBody

Raises:

NotImplementedError – If the bbox is 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:

PoseBody

Raises:

NotImplementedError – If the get_points is 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:

PoseBody

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:

PoseBody

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:

PoseBody

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:

PoseBody

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:

PoseBody

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:

PoseBody

tensor_reader = 'ABSTRACT-DO-NOT-USE'
tensorflow()[source]

Converts current PoseBody representation to TensorflowPoseBody.

Returns:

Converted PoseBody object.

Return type:

TensorflowPoseBody

Raises:

NotImplementedError – If tensorflow is not implemented.

torch()[source]

Converts current PoseBody to TorchPoseBody.

Returns:

The converted PoseBody object.

Return type:

TorchPoseBody

Raises:

NotImplementedError – If toch is not implemented.

write(version, buffer)[source]

Writes data to a file based on version of spec: in docs/spec.

Parameters:
  • version (float) – Version of the pose data to write.

  • buffer (BinaryIO) – Buffer to write the pose data to.

zero_filled()[source]

Creates a new PoseBody instance with data replaced by zeros.

Returns:

PoseBody instance with zero-filled data.

Return type:

PoseBody

Raises:

NotImplementedError – If the zero_filled is not implemented on class .