openalea.phenomenal.calibration.chessboard.Chessboard#
- class openalea.phenomenal.calibration.chessboard.Chessboard(square_size=50, shape=(7, 7), facing_angles=None)[source]#
Bases:
object- __init__(square_size=50, shape=(7, 7), facing_angles=None)[source]#
Instantiate a chessboard object
- Parameters:
square_size – length (world units) of the side of an elemental square of the chessboard
shape – (int, int) the number of square detected along chessboard width and height
facing_angles – a {camera_id: facing_angle} dict indicating for what value
topleft (of the turntable rotation consign the chessboard is facing the camera with topleft corner closest to)
image. (side of the)
Methods
__init__([square_size, shape, facing_angles])Instantiate a chessboard object
check_order([check_only])Re-order detected image points using facing angles
detect_corners(id_camera, rotation, image[, ...])Detection of pixel coordinates of chessboard corner points
dump(filename)get_corners_2d(id_camera)get_corners_local_3d([old_style])Chessboard local frame is defined by chessboard center, x axis along width (left >right), Y-axis along height (bottom -> up) and z axis normal to chessboard plane Chessboard corners are returned ordered line by line, from top left to bottom right
get_image(id_camera, rotation, data_dir[, ...])image_resolutions()load(filename)order_image_points(image_points, rotation, ...)order image points to match order of corner points (see details)
- detect_corners(id_camera, rotation, image, check_order=True, image_id=None)[source]#
Detection of pixel coordinates of chessboard corner points
- Parameters:
id_camera – (str) label of the camera that acquired the image
rotation – (int) rotation consign (positive, in degrees). The rotation consign is the rounded angle by which the turntable has turned before image acquisition
image – (image) numpy array of pixel intensities (rgb_color or grayscale)
check_order – (bool) Check if the detected image points are in the expected order: image points order should match local 3d coordinates order
image_id (str, optional) – if given, the image name is kept in image_ids instance
variable.
- Returns:
True if chessboard corner are found otherwise False.
Side effects: image points are added to the instance image point list
- get_corners_local_3d(old_style=False)[source]#
Chessboard local frame is defined by chessboard center, x axis along width (left >right), Y-axis along height (bottom -> up) and z axis normal to chessboard plane Chessboard corners are returned ordered line by line, from top left to bottom right
old_order returns in the expected order / origin for oldcalibration (phenomenal < 1.7.1)
- order_image_points(image_points, rotation, facing_angle, clockwise_rotation=True, check_only=False)[source]#
order image points to match order of corner points (see details)
- Parameters:
image_points – image points detected by openCV findChessboardCorners
rotation – (int) rotation consign (positive, in degrees). The rotation consign is the rounded angle by which the turntable has turned before image acquisition
facing_angle – the turntable rotation consign that make the chessboard face
camera (the)
clockwise_rotation (bool) – are targets rotating clockwise ? (default True)
check_only (bool) – if True, do not return ordered points, but a bool indicating whether input points were already ordered or not.
- Returns:
image_points, in the expected order
- Details:
Chessboard corners are detected with OpenCV findChessboardCorners function, that always return corners from top left to bottom right position on the image (left-right axis being chessboard width). This corresponds to expected order if chessboard upper side is pointing to the top of the image, but to the reversed expected order if chessboard upper side is pointing to the base of the image. We suppose that reversed order detection occurs for rotations +/- 90 deg far from facing_angle