ampy.processing

Module provides the processing of experimental video recordings and identifies ArUco markers placed on the robots’ upper surfaces

class ampy.processing.Processor

processing.Processor class provides interface for processing of experiment videos

cartesian_kinematics(bots_number: int, begin_frame: int, end_frame: int, get_each: int, ignore_codes: tuple, scale_parameters: tuple) list

Returns cartesian kinematics for particles in video with given processing parameters

Parameters:
  • bots_number – number of bots in video

  • begin_frame – frame to begin the processing

  • end_frame – frame to end the processing

  • get_each – frames decimation frequency

  • ignore_codes – markers to ignore while recognition

  • scale_parameters – pixels absolute scaling parameters

Returns:

list of frame-by-frame particles cartesian kinematic

field_center_auto(first_line_markers: tuple, second_line_markers: tuple, scale_parameters: tuple) tuple

Return center of the field calculated as the intersection of two lines which were defined by two pairs of markers

Parameters:
  • first_line_markers – markers IDs to define the first line

  • second_line_markers – markers IDs to define the second line

  • scale_parameters – pixels absolute scaling parameters

Returns:

field’s center

field_center_manual() tuple

Shows the video’s first frame and returns clicked point coordinates

Returns:

clicked point coordinates

get_time() int

Returns the time parameter

Returns:

the time parameter of extracted kinematics

static load_p(filename) list

Load system’s kinematics serialized by pickle :param filename: path to .pickle file :return: system’s kinematics

metric_constant(marker_size: float, scale_parameters: tuple) float

Returns factor that scale distances in pixel on video to distances in centimeters

Parameters:
  • marker_size – used ArUco marker size in centimeters

  • scale_parameters – pixels absolute scaling parameters

Returns:

scaling factor

static polar_kinematics(cartesian_kinematics: list, field_center: tuple) list

Returns kinematics extended by a polar angle (from 0 to 360 degrees clockwise in relation to X-axis) and a distance from field center for each particle

Parameters:
  • cartesian_kinematics – cartesian kinematics of a system

  • field_center – a center of a polar coordinates

Returns:

polar system’s kinematics

set_aruco_dict(dict_name: str)

Set ArUco dictionary you want to use to :param dict_name: the name of the dict

set_filename(filename: str) None

Set path to the file you want to process :param filename: the path

ampy.processing.calc_angle(point_a: tuple, point_b: tuple) float

Returns angle in degrees between OX-axis and (b-a) vector direction

Parameters:
  • point_a – vector’s begin point

  • point_b – vector’s end point

Returns:

angle in degrees

ampy.processing.calc_distance(point_a: tuple, point_b: tuple) float

Returns Euclidean distance between two points

Parameters:
  • point_a – first point

  • point_b – vector end point

Returns:

distance between points