openalea.phenomenal.calibration.calibration.Calibration

class openalea.phenomenal.calibration.calibration.Calibration(angle_factor=1, targets=None, cameras=None, target_points=None, image_points=None, reference_camera='side', clockwise_rotation=True, calibration_statistics=None, frames=None)[source]

Bases: object

A class for calibration of multi-views imaging systems (fixed cameras, rotating targets)

__init__(angle_factor=1, targets=None, cameras=None, target_points=None, image_points=None, reference_camera='side', clockwise_rotation=True, calibration_statistics=None, frames=None)[source]

Instantiate a Calibration object with calibration data

Parameters:
  • angle_factor – start value for angle_factor. angle_factor is a float multiplier of rotation consign to obtain actual rotation angle (default value: 1)

  • targets – a {target_id : CalibrationFrame,…} dict of targets to be used as starting guess for target frames, positioned using transformations of the base configuration of the imaging system (see CalibrationLayout)

  • cameras – a {camera_id: CalibrationCamera,…} dict of cameras to be used as starting guess for cameras, positioned using transformations of the base configuration of the imaging system (see CalibrationLayout)

  • target_points – a {target_id: [(x, y, z), …], …} dict of coordinates of target corner points, expressed in target local frame or native world frame if target_id == ‘world’

  • image_points – a {camera_id: {target_id : {rotation : [(u,v),…], …}, …,} dict of dict of dict of pixel coordinates of target corner points projected on camera images at a given rotation consign. The rotation consign is the rounded angle (degrees) by which the turntable has turned before image acquisition

  • reference_camera (str) – camera_id of the camera to be used to define world native frame (see details)

  • clockwise_rotation (bool) – are targets rotating clockwise ? (default True)

  • calibration_statistics (dict) – statitistics of current calibration

  • frames (dict) – a {frame_name: CalibrationFrame, …} dict of user-defined frames positioned in world

  • systems (native frame specifying alternative coordinates) –

Details:

Calibration allows finding position and parameters of cameras and targets and compute the projection functions of cameras from different use-defined frames The world 3D coordinates are natively expressed in the frame defined by the axis of rotation and a reference camera as follow:

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

  • The altitude of the reference camera defines Z=0.

  • The vertical plane around Z+ intercepting the reference camera, oriented from the camera to the axe of

rotation, defines world Y+ axis

The world coordinates can be redefined by further positioning user-defined frames in this native frame.

Methods

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

Instantiate a Calibration object with calibration data

calibrate([fit_angle_factor, ...])

Optimise the cameras and targets parameters to minimise the distance between observed image points and projections on images of target points

calibration_error([all_pars])

dump(filename)

find_camera(image_points, target_points[, ...])

Find camera parameters from clicked image points of known 3D target points

find_frame(image_points, frame_points[, ...])

Find Frame parameters and 3D local (frame based) coordinates of points from paired image coordinates

find_parameters()

find_points(image_points[, start, niter])

Find native 3D world coordinates of points from paired image coordinates on multiple cameras

fit_errors(x0)

fit_function(x0)

frame_lines(view, angle[, frame, l, w, at])

from_dict(save_class)

get_frame([frame])

get_image_shape(id_camera)

get_parameters()

get_projection(id_camera, rotation[, ...])

get_target_points(id_target)

get_target_projected(id_camera, id_target, ...)

get_turntable_frame(rotation)

load(filename)

set_values([targets, target_points, ...])

split_parameters(x0)

target_mask(id_camera, id_target, rotation)

Get image coordinate of a mask arround the target

turntable_frame(rotation[, angle_factor, ...])

Frame attached to turntable.

world_frame(camera)

World frame defined by an alternative camera positioned in the current reference camera world frame

calibrate(fit_angle_factor=True, fit_aspect_ratio=True, fit_reference_camera=True, fit_targets=True, fit_cameras=True, verbose=True)[source]

Optimise the cameras and targets parameters to minimise the distance between observed image points and projections on images of target points

Args:

fit_angle_factor: should angle_factor be fitted ? (default True) fit_reference_camera: should reference camera parameters be fitted ? (default True) fit_targets: should target frame parameters be fitted ? (default True) fit_cameras: should other than reference camera parameters be fitted ? (default True) verbose: should total error be printed during optimisation (default True)

Returns:

the mean calibration reprojection error (pixels)

find_camera(image_points, target_points, image_size=None, fixed_parameters=None, guess=None, niter=10)[source]

Find camera parameters from clicked image points of known 3D target points

Parameters:
  • image_points – an array-like list of image coordinates of remarkable points

  • target_points – an array-like list of 3D coordinates of remarkable points

  • image_size – (width, height) tuple describing image dimension (pixels). Alternatively the name of an existing camera with the same shape. If None, the shape of the reference camera is used

  • fixed_parameters – a {parameter_name: value} dict of fixed (unfitted) camera parameters. Valid parameters names are ‘_pos_x’, ‘_pos_y’, ‘_pos_z’, ‘_rot_x’, ‘_rot_y’, ‘_rot_z’, ‘_focal_length_x’, ‘_aspect_ratio’

  • guess – a guessed Calibration camera

  • niter – (int) the number of iteration of the basin-hopping optimisation algorithm

Returns:

A calibrated CalibrationCamera

find_frame(image_points, frame_points, fixed_parameters=None, start=None)[source]

Find Frame parameters and 3D local (frame based) coordinates of points from paired image coordinates

Parameters:
  • image_points – a {camera_id: [(u1,v1),…], …} dict of list of pixel coordinates of frame points

  • frame_points – an array-like list of 3D points coordinates, expressed in local coordinate of the searched frame. keywords ‘x’, ‘y’ and ‘z’ can be used to specify an unknown coordinate

  • fixed_parameters – a {parameter_name: value} dict of fixed (unfitted) frame parameters. Valid parameters names are ‘_pos_x’, ‘_pos_y’, ‘_pos_z’, ‘_rot_x’, ‘_rot_y’, ‘_rot_z’ start : a frame to be used as guess

Returns:

A CalibrationFrame and the list of 3D coordinates matching frame_points

find_points(image_points, start=None, niter=100)[source]

Find native 3D world coordinates of points from paired image coordinates on multiple cameras

Parameters:
  • image_points – a {camera_id: [(u1,v1),…], …} dict of list of pixel coordinates of remarkable points

  • images (taken on several) –

  • start (optional) – a array-like list of 3D points guesses

  • niter – (int) the number of iteration of the basin-hopping optimisation algorithm

Returns:

An array of 3D coordinates of points

target_mask(id_camera, id_target, rotation, border=2)[source]

Get image coordinate of a mask arround the target

Parameters:

border – the size of the border (in square_size units)

static turntable_frame(rotation, angle_factor=1, clockwise=True)[source]

Frame attached to turntable. This correspond to a rotation of the world native frame.

Parameters:
  • rotation – the rotation consign of the turning table

  • angle_factor – a float multiplier of rotation consign to obtain actual rotation angle

  • clockwise – is turntable rotating clockwise ?

Returns:

a frame object

static world_frame(camera)[source]

World frame defined by an alternative camera positioned in the current reference camera world frame