pose_format.pose_visualizer module

Classes:

FastAndUglyPoseVisualizer(pose[, thickness])

This class draws all frames as grayscale, without opacity based on confidence values.

PoseVisualizer(pose[, thickness])

A class for visualizing Pose objects using OpenCV.

class pose_format.pose_visualizer.FastAndUglyPoseVisualizer(pose, thickness=None)[source]

Bases: PoseVisualizer

This 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: object

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