camera_calibration¶
The camera_calibration package contains a user-friendly calibration tool, cameracalibrator. This tool uses the following Python classes, which conveniently hide some of the complexities of using OpenCV’s calibration process and chessboard detection, and the details of constructing a ROS CameraInfo message. These classes are documented here for people who need to extend or make a new calibration tool.
For details on the camera model and camera calibration process, see http://docs.opencv.org/master/d9/d0c/group__calib3d.html
-
class
camera_calibration.calibrator.
MonoCalibrator
(*args, **kwargs)¶ Calibration class for monocular cameras:
images = [cv2.imread("mono%d.png") for i in range(8)] mc = MonoCalibrator() mc.cal(images) print mc.as_message()
-
as_message
()¶ Return the camera calibration as a CameraInfo message
-
cal
(images)¶ Calibrate camera from given images
-
cal_fromcorners
(good)¶ Parameters: good ([(corners, ChessboardInfo)]) – Good corner positions and boards
-
collect_corners
(images)¶ Parameters: images (list of cvMat
) – source images containing chessboardsFind chessboards in all images.
Return [ (corners, ChessboardInfo) ]
-
do_tarfile_save
(tf)¶ Write images and calibration solution to a tarfile object
-
from_message
(msg, alpha=0.0)¶ Initialize the camera calibration from a CameraInfo message
-
handle_msg
(msg)¶ Detects the calibration target and, if found and provides enough new information, adds it to the sample database.
Returns a MonoDrawable message with the display image and progress info.
-
static
linear_error
(corners, b)¶ Returns the linear error for a set of corners detected in the unrectified image.
-
linear_error_from_image
(image)¶ Detect the checkerboard and compute the linear error. Mainly for use in tests.
-
remap
(src)¶ Parameters: src ( cvMat
) – source imageApply the post-calibration undistortion to the source image
-
set_alpha
(a)¶ Set the alpha value for the calibrated camera solution. The alpha value is a zoom, and ranges from 0 (zoomed in, all pixels in calibrated image are valid) to 1 (zoomed out, all pixels in original image are in calibrated image).
-
undistort_points
(src)¶ Parameters: src ( cvMat
) – N source pixel points (u,v) as an Nx2 matrixApply the post-calibration undistortion to the source points
-
-
class
camera_calibration.calibrator.
StereoCalibrator
(*args, **kwargs)¶ Calibration class for stereo cameras:
limages = [cv2.imread("left%d.png") for i in range(8)] rimages = [cv2.imread("right%d.png") for i in range(8)] sc = StereoCalibrator() sc.cal(limages, rimages) print sc.as_message()
-
as_message
()¶ Return the camera calibration as a pair of CameraInfo messages, for left and right cameras respectively.
-
cal
(limages, rimages)¶ Parameters: - limages (list of
cvMat
) – source left images containing chessboards - rimages (list of
cvMat
) – source right images containing chessboards
Find chessboards in images, and runs the OpenCV calibration solver.
- limages (list of
-
chessboard_size
(lcorners, rcorners, board, msg=None)¶ Compute the square edge length from two sets of matching undistorted points given the current calibration. :param msg: a tuple of (left_msg, right_msg)
-
collect_corners
(limages, rimages)¶ For a sequence of left and right images, find pairs of images where both left and right have a chessboard, and return their corners as a list of pairs.
-
do_tarfile_save
(tf)¶ Write images and calibration solution to a tarfile object
-
epipolar_error
(lcorners, rcorners)¶ Compute the epipolar error from two sets of matching undistorted points
-
epipolar_error_from_images
(limage, rimage)¶ Detect the checkerboard in both images and compute the epipolar error. Mainly for use in tests.
-
from_message
(msgs, alpha=0.0)¶ Initialize the camera calibration from a pair of CameraInfo messages.
-
set_alpha
(a)¶ Set the alpha value for the calibrated camera solution. The alpha value is a zoom, and ranges from 0 (zoomed in, all pixels in calibrated image are valid) to 1 (zoomed out, all pixels in original image are in calibrated image).
-