openalea.phenomenal.calibration.calibration.Calibrator

class openalea.phenomenal.calibration.calibration.Calibrator(south_camera, cameras=None, targets=None, chessboards=None, image_paths=None, clockwise_rotation=True, world_unit='mm', data_dir='.', calibration_dir='./Calibration')[source]

Bases: object

Class for end to end calibration of rotating multiview acquisition system

__init__(south_camera, cameras=None, targets=None, chessboards=None, image_paths=None, clockwise_rotation=True, world_unit='mm', data_dir='.', calibration_dir='./Calibration')[source]

Setup Calibrator with the calibration layout

Parameters:
  • south_camera – a (camera_id, inclination, distance) tuple defining the approximative position of the south camera. The south camera is used to define world frame during and after calibration (see details bellow). camera_id is a string referencing the camera, inclination is the (approximative) angle (degree, positive) between the axis of rotation and the axe passing through the turntable center and camera optical center, and distance is the (approximative) distance from turntable center to camera optical center (in world units).

  • cameras – a {camera_id: (inclination, distance, rotation_to_south), … } dict of 3-tuples specifying the approximative position of cameras (other than south camera). camera_id is a string referencing the camera, inclination is the (approximative) angle (degree, positive) between the axis of rotation and the axe passing through the turntable center and camera optical center, distance is the (approximative) distance from turntable center to camera optical center (in world units), and rotation_to_south is the (approximative) rotation angle (degrees, positive in the direction of rotation of the turntable) that align the camera to south.

  • targets – a {target_id: (inclination, rotation_to_south), …} dict of 2-tuples specifying the approximative position of calibration targets. target_id is a string referencing the target, inclination is the angle (degree, positive) between the axis of rotation and target normal, and rotation_to_south is the (approximative) rotation angle (degrees, positive in the direction of rotation of the turntable that align the target normal(or target base) toward south.

  • chessboards – a {target_id: (between_corners, corners_h, corners_v), …} dict of tuples describing the layout of chessboards corners points (intersections of cheesboard squares) associated to a target. target_id is a string referencing the target, between_corners is the distance (in world unit) between two corner points, corners_h is the number of corners in the horizontal direction, corners_v in the number of corners in the vertical direction.

  • image_paths – a {camera_id : {rotation_angle : path, …},…} nested dict of image paths pointing to the image camera ‘camera_id’ after a rotation of ‘rotation_angle’ degrees of the turntable. Path are relative to data_dir or absolute paths if data_dir is None

  • clockwise_rotation – (bool): is the turntable rotating clockwise ? (default True)

  • world_unit (str) – a label describing world units

  • data_dir – the path of the directory containing images

  • calibration_dir – the path of the directory to be used for calibration outputs

Details:

The world 3D coordinates are expressed in a ‘native’ frame defined by the axis of rotation and the south camera as follows:

  • The axis of rotation of the rotating system, oriented toward the sky, defines the world Z+.

  • The altitude of the south camera defines world origin (Z=0).

  • the axis originating at south camera optical center and passing at world origin defines Y+.

The world coordinates can be redefined by positioning user-defined frames in this native frame after calibration (see e.g. ‘add_target_frame’ or ‘add_pot_frame’ methods)

Methods

__init__(south_camera[, cameras, targets, ...])

Setup Calibrator with the calibration layout

abspath(path)

aiming_angle(camera_id, target_id, rotation)

The angle between camera Z- (opposite camera look-at axis) and target Z+ for a given rotation

alpha(rotation)

calibrate([verbose])

Compute calibration

check_dir(path)

check_image_points([resize])

check_target_frame(calibration[, resize, l])

check_target_masks(masks[, resize])

detect_corners([cameras, masks, ...])

Detection of pixel coordinates of chessboard corner points

load_image_points([image_points])

load image points

pot_frame(v_pot, rail_orientation, calibration)

Add a new world frame to calibration based orientation (x-axis) chosen from top and origin chosen on side image

quadrant_mask(quadrant, image)

roi_mask(image)

save_image_points([prefix])

save image points to calibration dir

target_frame(calibration)

Add a new world frame in calibration, similar to native frame, but whose origin is at the mean height of targets centers

aiming_angle(camera_id, target_id, rotation)[source]

The angle between camera Z- (opposite camera look-at axis) and target Z+ for a given rotation

calibrate(verbose=True)[source]

Compute calibration

detect_corners(cameras=None, masks=None, maximal_aiming_angle=65)[source]

Detection of pixel coordinates of chessboard corner points

Parameters:
  • cameras – a string or a list of elements specifying on which images should the detection be done. Element can either be a camera_id string or a (camera_id, list_of_angles) tuple specifying which angle to consider. If no angle are provided, all angles are considered. If cameras is None (default), all images are used

  • masks – a {target_id : [(camera_id, rotation, mask),…],…} dict of list of tuples specifying if a mask should be applied to the image before detection. mask can either be a string specifying the image quadrant (‘North’, ‘South’, ‘East’ or ‘West’) containing the target, a list of image coordinates (u,v) specifying the Region of Interest containing the target.

  • maximal_aiming_angle – images with a target that form an angle superior to this value are skipped

load_image_points(image_points=None)[source]

load image points

static pot_frame(v_pot, rail_orientation, calibration, dl=2000)[source]

Add a new world frame to calibration based orientation (x-axis) chosen from top and origin chosen on side image

save_image_points(prefix=None)[source]

save image points to calibration dir

static target_frame(calibration)[source]

Add a new world frame in calibration, similar to native frame, but whose origin is at the mean height of targets centers