Graphic Classes

Description

These classes allow to convert the data from Sequence, Pose and Joint to display them in the Display functions.

WindowArea

Initialisation

class classes.graphic_classes.WindowArea(resolution, blit_coordinates=(0, 0), elements=None, height_window_in_meters=3.0)

Defines the size of part of the window and allows to convert and scale the coordinates of the joints to be displayed.

New in version 2.0.

Parameters:
  • resolution (tuple(int, int)) – A tuple containing the resolution of the window area, with horizontal and vertical number of pixels, respectively.

  • blit_coordinates (tuple(int, int), optional) – A tuple containing the coordinates at which the graphic_window should be placed on the main window.

  • elements (list(str), optional) – A list containing the elements that should be placed on the window area (e.g. "sequence1" or "video").

  • height_window_in_meters (int or float, optional) – Defines the distance, in meters, represented by the vertical number of pixels of the window area (by default: 3).

window_area

The pygame Surface containing the graphic elements, set during the initialisation.

Type:

pygame.Surface

resolution

A tuple containing the width and height of the window, in pixels.

Type:

tuple(int, int)

width

The width of the window, in pixels.

Type:

int

height

The height of the window, in pixels.

Type:

int

center_x

The mid-point on the x-axis of the window, in pixels.

Type:

int

center_y

The mid-point on the y-axis of the :attr:`window, in pixels.

Type:

int

blit_coordinates

A tuple containing the coordinates at which the graphic_window should be placed on the main window.

Type:

tuple(int, int)

elements

A list containing the elements that should be placed on the window area (e.g. "sequence1" or "video").

Type:

list(str)

height_window_in_meters

Defines the distance, in meters, represented by the vertical number of pixels of the window.

Type:

float

pixel_meter_scale

The real-life distance a pixel represents, in meters. For example, if the window area is 1000 pixels vertically, and the parameter height_area_in_meters is set on 1, each pixel will be equivalent to a square of 1 mm × 1 mm.

Type:

float

Methods

WindowArea.set_resolution(resolution)

Sets the resolution of the window area, and updates the attributes resolution, attr:width, attr:height, attr:center_x, attr:center_y and attr:window_area.

New in version 2.0.

Parameters:

resolution (tuple(int, int)) – A tuple containing the width and height of the window, in pixels.

WindowArea.set_blit_coordinates(blit_coordinates)

Sets the attribute blit_coordinates of the window area.

New in version 2.0.

Parameters:

blit_coordinates (tuple(int, int)) – A tuple containing the coordinates at which the graphic_window should be placed on the main window.

WindowArea.set_elements(elements)

Sets the attribute elements of the window area.

New in version 2.0.

Parameters:

elements (list(str)) – A list containing the elements that should be placed on the window area (e.g. "sequence1" or "video").

WindowArea.add_element(element)

Adds an element to the attribute elements of the window area.

New in version 2.0.

Parameters:

element (str) – A string representing an element that should be displayed on the window area.

WindowArea.remove_element(element)

Removes an element from the attribute elements of the window area, if it exists in the list.

New in version 2.0.

Parameters:

element (str) – A string representing an element that should be removed from the window area.

WindowArea.set_height_window_in_meters(height_window_in_meters)

Sets the attribute height_window_in_meters.

New in version 2.0.

Parameters:

height_window_in_meters (float) – Defines the distance, in meters, represented by the vertical number of pixels of the window area (by default: 3).

WindowArea.contains(element)

Returns True if the element specified as parameter exists in the attribute elements.

New in version 2.0.

Parameters:

element (str) – A string representing an element that may be contained in the window area.

WindowArea.convert_x(x, scale=1.0)

Converts the x “real” coordinate to a graphical coordinate to be displayed in the window area.

New in version 2.0.

Parameters:
  • x (float) – The value on the x-axis of a coordinate.

  • scale (float, optional) – The scale at which to convert the coordinate. A bigger scale will zoom in on the axis.

Returns:

The coordinate of the pixel on the x-axis of the window area.

Return type:

int

WindowArea.convert_y(y, scale=1.0)

Converts the y “real” coordinate to a graphical coordinate to be displayed in the window area.

New in version 2.0.

Parameters:
  • y (float) – The value on the y-axis of a coordinate.

  • scale (float, optional) – The scale at which to convert the coordinate. A bigger scale will zoom in on the axis.

Returns:

The coordinate of the pixel on the y-axis of the window area.

Return type:

int

WindowArea.get_resolution()

Returns a tuple containing the resolution of the window area.

New in version 2.0.

Returns:

The resolution of the window area, in pixels, horizontally and vertically, respectively.

Return type:

tuple(int, int)

WindowArea.fill(color)

Fills the window with a given color.

New in version 2.0.

Parameters:
  • tuple(int (int) or) – A RGB or RGBA color tuple.

  • int – A RGB or RGBA color tuple.

  • tuple(int – A RGB or RGBA color tuple.

  • int – A RGB or RGBA color tuple.

  • int – A RGB or RGBA color tuple.

  • int) – A RGB or RGBA color tuple.

WindowArea.blit_background_surface()

Blits the background surface on the window area. This function can be used to paint the background surface in a specific color.

New in version 2.0.

WindowArea.blit(surface, position)

Blits a surface onto the window area, at a specified position.

New in version 2.0.

Parameters:
  • surface (pygame.Surface) – A pygame Surface.

  • position (tuple(int, int)) – The position on the window area where to place the top-left corner of the surface.

WindowArea.show(window)

Blits the window area onto a window.

New in version 2.0.

Parameters:

window – A pygame Surface.

Timer

Initialisation

class classes.graphic_classes.Timer(speed=1.0)

Creates and sets a timer.

New in version 2.0.

clock

A Pygame clock object.

Type:

pygame.time.Clock

timer

A timer, in milliseconds.

Type:

float

speed

A factor that multiplies the tick of the clock (default: 1). A value of 2 would make the timer go twice as fast.

Type:

float

play

A boolean indicating whether the timer is counting (True) or on pause (False).

Type:

boolean

last_tick

The value of the last tick (in milliseconds) added to the timer.

Type:

int

last_full_second

The value of the last second fully elapsed. For example, if the timer is set on 5263 ms, this function will return 5.

Type:

int

update_marker

A boolean indicating if the timer has been modified. This boolean is initialised on False, and turns to True whenever the method Timer.reset() or Timer.set() is called. This attribute is then used as a marker to know if other objects must be reset. The parameter should return to False by using the method Timer.end_update().

Type:

bool

Methods

Timer.set_timer(t)

Sets the timer at a specific value.

New in version 2.0.

Parameters:

t (float) – The value, in milliseconds, to set the timer on.

Timer.set_speed(speed)

Sets the displaying speed.

New in version 2.0.

Parameters:

speed (float) – A factor that multiplies the tick of the clock. A value of 2 would make the timer go twice as fast.

Timer.get_timer()

Returns the value of the attribute timer.

New in version 2.0.

Returns:

The time contained in the attribute timer, in milliseconds.

Return type:

float

Timer.get_last_tick()

Returns the value of the attribute last_tick.

New in version 2.0.

Returns:

The value of the last tick added to the timer.

Return type:

int

Timer.get_last_full_second()

Returns the value of the attribute last_full_second.

New in version 2.0.

Returns:

The value of the last second fully elapsed. For example, if the attribute timer is set on 5263 ms, this function will return 5.

Return type:

int

Timer.reset()

Resets the timer to 0, and sets the attribute update_marker to True.

New in version 2.0.

Timer.pause()

Sets the attribute play on False, preventing the timer from being updated.

New in version 2.0.

Timer.unpause()

Sets the attribute play on True, reestablishing the updating of the timer.

New in version 2.0.

Timer.update()

Adds the tick of the pygame.time.Clock object to the timer if the play is set on True.

New in version 2.0.

Timer.end_update()

Sets the attribute update_marker to False.

New in version 2.0.

GraphicSequence

Initialisation

class classes.graphic_classes.GraphicSequence(sequence, graphic_window, start_pose=0, verbosity=1, **kwargs)

Graphical counterpart to the class Sequence. This class allows to convert the original coordinates of the joints into graphical coordinates.

New in version 2.0.

Parameters:
  • sequence (Sequence) – A Sequence instance.

  • graphic_window (WindowArea) – The window object, where to display the sequence.

  • start_pose (int, optional) – The index of the pose at which to start the sequence.

  • verbosity (int, optional) –

    Sets how much feedback the code will provide in the console output:

    • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

    • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

    • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

  • **kwargs (dict) – A dictionary of optional arguments. See a complete list of the optional arguments in Keyword arguments.

sequence

The Sequence instance, passed as parameter upon initialisation.

Type:

Sequence

current_pose_index

The index of the pose currently being in display. It is initialised with the value from the parameter start_pose.

Type:

int

poses

List of all the _GraphicPose objects counterparts of the Pose objects.

Type:

list(_GraphicPose)

shape_joint

The shape that the joints will have: “circle” (default) or “square”. Can be modified via _GraphicSequence._shape_joint().

Type:

str

color_joint_default

The color of the joints (default: “white”). Can be modified via _GraphicSequence._set_color_joint_default().

Type:

tuple(int, int, int, int)

color_joint_corrected

The color of the joints corrected by Sequence.correct_jitter() or Sequence.correct_zeros() (default: “green”). Can be modified via _GraphicSequence._set_color_joint_corrected().

Type:

tuple(int, int, int, int)

color_line

The color of the lines between the joints (default: “grey”). Can be modified via _GraphicSequence._set_color_line().

Type:

tuple(int, int, int, int)

width_line

The width of the lines connecting the joints, in pixels (default: 1). Can be modified via _GraphicSequence._set_width_line().

Type:

int

size_joint_default

The radius (if shape_joint is set on “circle”) or width/height (if shape_joint is set on “square”), in pixels, of the joints not covered by size_joint_head and size_joint_hand (default: 10). Can be modified via _GraphicSequence._set_size_joint_default().

Type:

int

size_joint_hand

The radius (if shape_joint is set on “circle”) or width/height (if shape_joint is set on “square”), in pixels, of the “HandRight” and “HandLeft” joints (Kinect) or the “HandOutRight” and “HandOutLeft” joints (Kualysis) (default: 20). Can be modified via _GraphicSequence._set_size_joint_hand().

Type:

int

size_joint_head

The radius (if shape_joint is set on “circle”) or width/height (if shape_joint is set on “square”), in pixels, of the “Head” joint (Kinect) or the “HeadFront” joint (Kualysis) (default: 50). Can be modified via _GraphicSequence._set_size_joint_head().

Type:

int

scale_joint

Scaling factor for the size of the joints (default: 1). Can be modified via _GraphicSequence._set_scale().

Type:

float

joints_to_show

A list of joint labels to be displayed.

Type:

list(str)

joint_labels_top

A list of the joints from the top of the body, loaded from res/kinect_joint_labels_top.txt or res/kualisys_joint_labels_top.txt.

Type:

list(str)

joint_labels_all

A list of all the joints from the body, concatenating the list from joint_labels_top to the list contained in either res/kinect_joint_labels_bottom.txt or res/kualisys_joint_labels_top.txt.

Type:

list(str)

connections_to_show

A list of the connections that will be displayed as lines between joints.

Type:

list(list(str, str))

connections_top

A list of the connections from the top of the body, loaded from res/kinect_skeleton_connections_top.txt or res/kualisys_skeleton_connections_top.txt.

Type:

list(list(str, str))

connections_all

A list of all the connections from the body, concatenating the list from connections_top to the list contained in either res/kinect_skeleton_connections_bottom.txt or res/kualisys_skeleton_connections_bottom.txt.

Type:

list(list(str, str))

ignore_bottom

Defines if to ignore the joints and lines located in the lower half of the body (default value: False). Can be modified via _GraphicSequence._set_ignore_bottom().

Type:

bool

show_lines

Defines if to show the lines connecting the joints (default: True). Can be modified via _GraphicSequence._set_show_lines().

Type:

bool

joint_surfaces

A dictionary containing the different pygame.Surface objects representing single joints.

Type:

dict(str: pygame.Surface)

shift_x

The number of pixels to shift the display of the joints on the horizontal axis. Can be modified via _GraphicSequence._set_shift_x().

Type:

int

shift_y

The number of pixels to shift the display of the joints on the vertical axis. Can be modified via _GraphicSequence._set_shift_y().

Type:

int

zoom_level

Defines the zoom level compared to the original view. A zoom level of 2 will make the joints appear twice as close.

Type:

float

Methods

GraphicSequence._load_poses(graphic_window, verbosity=1)

Converts a Sequence into a _GraphicSequence and add them to the poses attribute.

New in version 2.0.

Parameters:
  • graphic_window (WindowArea) – The window object, where to display the sequence.

  • verbosity (int, optional) –

    Sets how much feedback the code will provide in the console output:

    • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

    • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

    • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

GraphicSequence._load_joint_labels()

Loads two lists of joint labels, joint_labels_top and joint_labels_all, defining which joints will be displayed depending if the attribute ignore_bottom is set on True or False. The joint labels list are loaded from res/kinect_joint_labels_top.txt and res/kinect_joint_labels_bottom.txt or res/kualisys_joint_labels_top.txt and res/kualisys_joint_labels_bottom.txt.

New in version 2.0.

GraphicSequence._load_connections()

Loads the list of pairs of joints that will be connected by a line. This function automatically recognizes the system (Kinect or Kualisys) and creates two lists of connections, one for the top of the body (loaded from res/kinect_skeleton_connections_top.txt or res/kualisys_skeleton_connections_top.txt), and one concatenating this list with the connections for the bottom of the body (loaded from res/kinect_skeleton_connections_bottom.txt or res/kualisys_skeleton_connections_bottom.txt), which will be ignored if :attr:ignore_bottom is set on True.

New in version 2.0.

GraphicSequence._add_entry_joint_surfaces(entry, size, color)

Adds or modifies an entry in the dictionary of Surface objects joint_surfaces.

New in version 2.0.

Parameters:
  • entry (str) –

    The name of the entry. Typically, it should be “joint_X_Y” where:

    • X is the size of the joint, influenced by its position on the body (default, hand or head)

    • Y is the color of the joint, depending on if it was corrected or not (default or corrected).

  • size (int) – The radius (if shape_joint is set on “circle”) or width/height (if shape_joint is set on “square”), in pixels, of the joint.

  • color (tuple(int, int, int, int)) – The color of the joint.

GraphicSequence._generate_all_joint_surfaces()

Generates all the Surface objects in self.joint_surfaces.

New in version 2.0.

GraphicSequence.get_timestamp()

Returns the timestamp of the current frame, in milliseconds.

New in version 2.0.

Returns:

The timestamp of the current frame, in milliseconds.

Return type:

float

GraphicSequence.get_duration()

Returns the duration of the sequence, in milliseconds.

New in version 2.0.

Returns:

The duration of the sequence, in milliseconds.

Return type:

float

GraphicSequence.get_number_of_poses()

Returns the number of poses in the sequence.

New in version 2.0.

Returns:

The number of poses in the sequence.

Return type:

int

GraphicSequence.get_current_pose_index()

Returns the index of the pose currently being displayed.

New in version 2.0.

Returns:

The index of the pose currently being displayed.

Return type:

int

GraphicSequence.set_color_background(color)

Sets the attribute color_background.

New in version 2.0.

Parameters:

color (tuple(int, int, int), tuple(int, int, int, int) or str) –

The color displayed in the background of the sequence (default: “black”). This parameter can be:

  • A RGB or RGBA tuple (e.g. (255, 255, 255) or (255, 255, 255, 255)). In the case of an RGBA tuple, the last number is used for opacity.

  • A hexadecimal value, with a leading number sign ("#"), with or without opacity value.

  • A string containing one of the 140 HTML/CSS color names).

GraphicSequence.set_shape_joint(shape_joint)

Sets the attribute shape_joint, and re-generates the Surface objects in self.joint_surfaces.

New in version 2.0.

Parameters:

shape_joint (str) – The shape that the joints will have: “circle” or “square”.

GraphicSequence.set_color_joint_default(color)

Sets the attribute color_joint_default, and re-generates the relevant Surface objects in self.joint_surfaces.

New in version 2.0.

Parameters:

color (tuple(int, int, int), tuple(int, int, int, int) or str) –

The color of the joint (default: “white”). This parameter can be:

  • A RGB or RGBA tuple (e.g. (255, 255, 255) or (255, 255, 255, 255)). In the case of an RGBA tuple, the last number is used for opacity.

  • A hexadecimal value, with a leading number sign ("#"), with or without opacity value.

  • A string containing one of the 140 HTML/CSS color names).

GraphicSequence.set_color_joint_corrected(color)

Sets the attribute color_joint_corrected, and re-generates the relevant Surface objects in self.joint_surfaces.

New in version 2.0.

Parameters:

color (tuple(int, int, int), tuple(int, int, int, int) or str) –

The color of the joints corrected by Sequence.correct_jitter() or Sequence.correct_zeros() (default: “sheen green”). This parameter can be:

  • A RGB or RGBA tuple (e.g. (255, 255, 255) or (255, 255, 255, 255)). In the case of an RGBA tuple, the last number is used for opacity.

  • A hexadecimal value, with a leading number sign ("#"), with or without opacity value.

  • A string containing one of the 140 HTML/CSS color names).

GraphicSequence.set_color_line(color)

Sets the attribute color_line.

New in version 2.0.

Parameters:

color (tuple(int, int, int), tuple(int, int, int, int) or str) –

The color of the lines between the joints (default: “grey”). This parameter can be:

  • A RGB or RGBA tuple (e.g. (255, 255, 255) or (255, 255, 255, 255)). In the case of an RGBA tuple, the last number is used for opacity.

  • A hexadecimal value, with a leading number sign ("#"), with or without opacity value.

  • A string containing one of the 140 HTML/CSS color names).

GraphicSequence.set_width_line(width)

Sets the attribute width_line.

New in version 2.0.

Parameters:

width (int) – The width of the lines connecting the joints.

GraphicSequence.set_size_joint_default(size)

Sets the attribute size_joint_default, and re-generates the relevant Surface objects in self.joint_surfaces.

New in version 2.0.

Parameters:

size (int) – The radius (if shape_joint is set on “circle”) or width/height (if shape_joint is set on “square”), in pixels, of the joints not covered by size_joint_head and size_joint_hand (default: 10).

GraphicSequence.set_size_joint_hand(size)

Sets the attribute size_joint_hand, and re-generates the relevant Surface objects in self.joint_surfaces.

New in version 2.0.

Parameters:

size (int) – The radius (if shape_joint is set on “circle”) or width/height (if shape_joint is set on “square”), in pixels, of the “HandRight” and “HandLeft” joints (Kinect) or the “HandOutRight” and “HandOutLeft” joints (Kualysis) (default: 20).

GraphicSequence.set_size_joint_head(size)

Sets the attribute size_joint_head, and re-generates the relevant Surface objects in self.joint_surfaces.

New in version 2.0.

Parameters:

size (int) – The radius (if shape_joint is set on “circle”) or width/height (if shape_joint is set on “square”), in pixels, of the “Head” joint (Kinect) or the “HeadFront” joint (Kualysis) (default: 50).

GraphicSequence.set_scale_joint(scale_joint)

Sets the attribute scale_joint, and re-generates the relevant Surface objects in self.joint_surfaces.

New in version 2.0.

Parameters:

scale_joint (float) – Scaling factor for the size of the joints (default: 1).

GraphicSequence.set_ignore_bottom(ignore_bottom)

Sets the attribute ignore_bottom and updates the attribute :attr:connections, which contains a list of the lines that will be displayed.

New in version 2.0.

Parameters:

ignore_bottom (bool, optional) – If set on True, the joints below the waist will not be displayed. If set on False (default), all the joints will be displayed. For a complete list of joints being displayed or not, see Display the sequence.

GraphicSequence.set_show_lines(show_lines)

Sets the attribute show_lines.

New in version 2.0.

Parameters:

show_lines (bool) – If set on True (default), the graphic sequence will include lines between certain joints, to create a skeleton. If set on False, only the joints will be displayed.

GraphicSequence.set_show_joints_corrected(show_joints_corrected)

Sets the attribute show_joints_corrected.

New in version 2.0.

Parameters:

show_joints_corrected (bool) – If set on True, the joints corrected by Sequence.correct_jitter() or Sequence.correct_zeros() will appear colored by color_joint_corrected. Otherwise, the joints will appear colored by color_joint_default.

GraphicSequence.set_shift_x(shift_x)

Sets the attribute shift_x.

New in version 2.0.

Parameters:

shift_x (int) – The number of pixels to shift the sequence on the horizontal axis.

GraphicSequence.set_shift_y(shift_y)

Sets the attribute shift_y.

New in version 2.0.

Parameters:

shift_y (int) – The number of pixels to shift the sequence on the horizontal axis.

GraphicSequence.set_zoom_level(zoom_level, window_area, mouse_pos)

Sets the attribute zoom_level.

New in version 2.0.

Parameters:
  • zoom_level (float) – Defines the zoom level compared to the original view. A zoom level of 2 will make the joints appear twice as close.

  • window_area (WindowArea) – A WindowArea object.

  • mouse_pos (tuple(int, int)) – The position of the mouse, in pixels.

GraphicSequence.toggle_ignore_bottom()

Sets the attribute ignore_bottom on the opposite of its current value.

..versionadded:: 2.0

GraphicSequence.toggle_show_lines()

Sets the attribute show_lines on the opposite of its current value.

..versionadded:: 2.0

GraphicSequence.toggle_show_joints_corrected()

Sets the attribute show_joints_corrected on the opposite of its current value.

..versionadded:: 2.0

GraphicSequence.set_pose_from_timestamp(timestamp, method='lower', verbosity=1)

Sets the attribute current_pose from the value of the timer.

New in version 2.0.

Parameters:
  • timestamp (float) – A timestamp, in milliseconds.

  • method (str) –

    Defines which pose is selected based on the timestamp.

    • If set on "closest" (default), the closest pose from the timestamp is selected.

    • If set on "below", "lower" or "under", the closest pose below the timestamp is selected.

    • If set on "above", "higher" or "over", the closest pose above the timestamp is selected.

  • verbosity (int, optional) –

    Sets how much feedback the code will provide in the console output:

    • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

    • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

    • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

GraphicSequence.set_pose_from_index(pose_index, timer)

Sets the attribute current_pose from the value specified in the timer.

New in version 2.0.

Parameters:
  • pose_index (int) – The index of the pose.

  • timer (Timer) – A Timer instance.

GraphicSequence.next_pose(timer, verbosity=1)

Increments the parameter current_pose; if the last pose is reached, the function _GraphicSequence.reset() is called.

New in version 2.0.

timer: Timer

A Timer object.

verbosity: int, optional

Sets how much feedback the code will provide in the console output:

  • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

  • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

  • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

GraphicSequence.previous_pose(timer, verbosity=1)

Decrements the parameter current_pose; if the first pose is reached, the pose is set on the last one from the sequence.

New in version 2.0.

timer: Timer

A Timer object.

verbosity: int, optional

Sets how much feedback the code will provide in the console output:

  • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

  • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

  • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

GraphicSequence.reset(timer)

Sets the current pose to the first of the sequence, and resets the timer to 0.

New in version 2.0.

timer: Timer

A Timer object.

GraphicSequence.apply_events(event, timer, verbosity=1)

Gets a Pygame keypress event, and calls the _GraphicSequence._next_pose() if the key pressed is the right arrow key, or _GraphicSequence._previous_pose() if the key pressed is the left arrow key.

New in version 2.0.

Parameters:
  • event (Pygame.event) – A Pygame event.

  • timer (Timer) – A Timer object.

  • verbosity (int, optional) –

    Sets how much feedback the code will provide in the console output:

    • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

    • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

    • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

GraphicSequence.play(window_area, timer)

Displays on the window object the poses in real time.

New in version 2.0.

Parameters:
  • window_area (WindowArea) –

    A GraphicWindow instance containing a pygame.Surface element on which to display the sequence.

  • timer (Timer) – A Timer object.

GraphicSequence.show_pose(window_area)

Displays the pose with the index current_pose on the window object.

New in version 2.0.

Parameters:

window_area (WindowArea) –

A GraphicWindow instance containing a pygame.Surface element on which to display the sequence.

GraphicPose

Initialisation

class classes.graphic_classes.GraphicPose(pose, graphic_window, verbosity=1)

Graphical counterpart to the class Pose. This class allows to save the _GraphicJoint objects.

New in version 2.0.

Parameters:
  • pose (Pose) – A Pose instance.

  • graphic_window (WindowArea) – The window object, where to display the sequence.

  • verbosity (int, optional) –

    Sets how much feedback the code will provide in the console output:

    • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

    • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

    • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

pose

The Pose instance, passed as parameter upon initialisation.

Type:

Pose

joints

List of all the _GraphicJoint objects counterparts of the Joint objects.

Type:

dict(str: _GraphicJoint)

Methods

GraphicPose._load_joints(graphic_window, verbosity=1)

Creates _GraphicJoint elements for each joint of the pose and add them to the joints attribute.

New in version 2.0.

Parameters:
  • graphic_window (WindowArea) – The window object, where to display the sequence.

  • verbosity (int, optional) –

    Sets how much feedback the code will provide in the console output:

    • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

    • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

    • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

GraphicPose.show_line(graphic_window, connection, color_line, width_line, shift_x=0, shift_y=0, zoom_level=1)

Shows a single line between two joints specified in connection on the window object.

New in version 2.0.

Parameters:
  • graphic_window (WindowArea) –

    A GraphicWindow instance containing a pygame.Surface element on which to display the sequence.

  • connection (str(list, list)) – A list of two joint labels to connect by a line.

  • color_line (tuple(int, int, int, int)) – The color of the lines connecting the joints.

  • width_line (int) – The width, in pixels, of the lines connecting the joints.

  • shift_x (int, optional) – The number of pixels to shift the display of the joints on the horizontal axis (default: 0).

  • shift_y (int, optional) – The number of pixels to shift the display of the joints on the vertical axis (default: 0).

  • zoom_level (float, optional) – Defines the zoom level compared to the original view. A zoom level of 2 will make the joints appear twice as close.

GraphicPose.show(graphic_window, joint_surfaces, joints_to_show, connections_to_show, color_line, width_line, show_lines, shift_x=0, shift_y=0, zoom_level=1)

Displays the pose on the window object.

New in version 2.0.

Parameters:
  • graphic_window (WindowArea) –

    A GraphicWindow instance containing a pygame.Surface element on which to display the sequence.

  • joint_surfaces

    A dictionary containing the different pygame.Surface objects representing single joints.

  • joints_to_show (list(str)) – A list of joint labels to be displayed.

  • connections_to_show (list(list(str, str))) – A list of lines to be displayed to connect joints.

  • color_line (tuple(int, int, int, int)) – The color of the lines connecting the joints.

  • width_line (int) – The width, in pixels, of the lines connecting the joints.

  • show_lines (bool, optional) – Defines if to show the lines connecting the joints (default: True).

  • shift_x (int, optional) – The number of pixels to shift the display of the joints on the horizontal axis (default: 0).

  • shift_y (int, optional) – The number of pixels to shift the display of the joints on the vertical axis (default: 0).

  • zoom_level (float, optional) – Defines the zoom level compared to the original view. A zoom level of 2 will make the joints appear twice as close.

GraphicJoint

Initialisation

class classes.graphic_classes.GraphicJoint(joint, graphic_window, verbosity=1)

Graphical counterpart to the class Joint. This class allows to convert the original coordinates and save them into graphical coordinates.

New in version 2.0.

Parameters:
  • joint (Joint) – A Joint instance.

  • graphic_window (WindowArea) – The window object, where to display the sequence.

  • verbosity (int, optional) –

    Sets how much feedback the code will provide in the console output:

    • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

    • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

    • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

joint

The Joint instance passed as parameter upon initialisation.

Type:

Joint

x

The x coordinate, in pixels.

Type:

float

y

The y coordinate, in pixels.

Type:

float

Methods

GraphicJoint.convert_coordinates(graphic_window, verbosity=1)

Converts the original coordinates into graphic coordinates.

New in version 2.0.

Parameters:
  • graphic_window (WindowArea) – The window object, where to display the sequence.

  • verbosity (int, optional) –

    Sets how much feedback the code will provide in the console output:

    • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

    • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

    • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

GraphicJoint.rotate(graphic_window, yaw=0, pitch=0, roll=0)

Sets the attributes x and y given three rotations from the original coordinates: yaw, pitch and roll.

New in version 2.0.

Warning

This function is experimental as of version 2.0.

Parameters:
  • graphic_window (WindowArea) – The window object, where to display the sequence.

  • yaw (float, optional) – The angle of yaw, or rotation on the x axis, in degrees (default: 0).

  • pitch (float, optional) – The angle of pitch, or rotation on the y axis, in degrees (default: 0).

  • roll (float, optional) – The angle of roll, or rotation on the z axis, in degrees (default: 0).

GraphicJoint.show(graphic_window, joint_surfaces, shift_x=0, shift_y=0, zoom_level=1)

Displays the joint on the window surface.

New in version 2.0.

Parameters:
  • graphic_window (WindowArea) –

    A GraphicWindow instance containing a pygame.Surface element on which to display the sequence.

  • joint_surfaces – A dictionary containing the elements representing the joints that can be displayed.

  • shift_x (int, optional) – The number of pixels to shift the display of the joints on the horizontal axis (default: 0).

  • shift_y (int, optional) – The number of pixels to shift the display of the joints on the vertical axis (default: 0).

  • zoom_level (float, optional) – Defines the zoom level compared to the original view. A zoom level of 2 will make the joints appear twice as close.

Video

Initialisation

class classes.graphic_classes.Video(path, resolution)

This class allows to store and display a video in a WindowArea.

New in version 2.0.

Parameters:
  • path (str) – The path of the video file.

  • resolution (tuple(int, int)) – The resolution of the window area, where the video should be displayed.

path

The path of the video file.

Type:

str

resolution

The resolution of the window area, where the video should be displayed.

Type:

tuple(int, int)

fps

The framerate of the video.

Type:

float

number_of_frames

The number of frames in the video.

Type:

int

current_frame_index

The index of the frame currently displayed.

Type:

int

current_frame_surface

A pygame Surface containing a frame of the video.

Type:

pygame.Surface

time_next_frame

The value of the timer at which the next frame should be displayed.

Type:

int

video

A VideoCapture object.

Type:

cv2.VideoCapture

Methods

Video._load_video()

Loads the video upon creating the video object.

New in version 2.0.

Video._load_frame()

Loads the next frame of the video and turns it in a pygame surface.

New in version 2.0.

Video.get_timestamp()

Returns the timestamp of the frame currently being displayed.

New in version 2.0.

Returns:

The timestamp of the frame currently being displayed, in milliseconds.

Return type:

float

Video.get_duration()

Returns the duration of the video, in seconds.

New in version 2.0.

Returns:

The duration of the video, in milliseconds.

Return type:

float

Video.get_number_of_frames()

Returns the total number of frames in the video.

New in version 2.0.

Returns:

The total number of frames in the video.

Return type:

int

Video.get_fps()

Returns the framerate of the video.

New in version 2.0.

Returns:

The number of frames per second of the video.

Return type:

float

Video.get_current_frame_index()

Returns the index of the frame currently being displayed.

New in version 2.0.

Returns:

The index of the frame currently being displayed.

Return type:

int

Video.set_frame_from_index(frame_index, verbosity=1)

Sets the frame to be displayed.

New in version 2.0.

Parameters:
  • frame_index (int) – The index of the target frame.

  • verbosity (int, optional) –

    Sets how much feedback the code will provide in the console output:

    • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

    • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

    • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

Video.set_frame_from_timestamp(timestamp, method='lower', verbosity=1)

Sets the frame depending on a Timer object.

New in version 2.0.

Parameters:
  • timestamp (float) – A timestamp, in milliseconds.

  • method (str) –

    Defines which frame is selected based on the timestamp.

    • If set on "closest" (default), the closest frame from the timestamp is selected.

    • If set on "below", "lower" or "under", the closest frame below the timestamp is selected.

    • If set on "above", "higher" or "over", the closest frame above the timestamp is selected.

  • verbosity (int, optional) –

    Sets how much feedback the code will provide in the console output:

    • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

    • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

    • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

Video.reset(verbosity=1)

Resets the video to the first frame.

New in version 2.0.

Parameters:

verbosity (int, optional) –

Sets how much feedback the code will provide in the console output:

  • 0: Silent mode. The code won’t provide any feedback, apart from error messages.

  • 1: Normal mode (default). The code will provide essential feedback such as progression markers and current steps.

  • 2: Chatty mode. The code will provide all possible information on the events happening. Note that this may clutter the output and slow down the execution.

Video.next_frame()

Loads the next frame of the video, or resets the video if the last frame has been reached.

New in version 2.0.

Video.show_frame(window_area)

Shows the current current_frame_surface in a provided window_area, without updating the timer, compared to show().

New in version 2.0.

Parameters:

window_area (WindowArea) – The WindowArea instance where to blit the video frame.

Video.show(window_area, timer)

Shows the current current_frame_surface in a provided window_area, and loads the next frame based on the timer.

New in version 2.0.

Parameters:

Keyword arguments

For the accepted keyboard arguments, see Keyword arguments.