User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
cs:camera_calibration:start [2016/08/21 19:16]
Brandon Kallaher created
— (current)
Line 1: Line 1:
-====== Camera Calibration ====== 
- 
-===== Overview ===== 
- 
-  * Since we use fisheye lenses and stereo rectification,​ both need to be carefully calibrated and saved before any vision code can be reliably used. For both of these tasks we use custom mono and stereo calibration programs located in the tools folder of the repo that utilize OpenCV calibration functions. 
-  * For standard webcams with normal FOV, you can use the standard calibration programs. For all wide angle lenses, you can use the new OpenCV fisheye camera model add in 2.4.11. Documentation for the standard camera model, and reference for both camera models can be found here. 
- 
-[[http://​docs.opencv.org/​doc/​tutorials/​calib3d/​camera_calibration/​camera_calibration.html|Standard Camera Tutorial]] 
- 
-[[http://​docs.opencv.org/​modules/​calib3d/​doc/​camera_calibration_and_3d_reconstruction.html|Calibration Reference]] 
- 
-===== Setup ===== 
- 
-  * Both mono calibration programs reference an xml file that contains information about the camera as well as a path to another xml file containing paths to the mono calibration images of the chessboard. The stereo versions grab images straight from an xml file containing the images in left/right order. 
-  * In order to setup the calibration you need to take multiple images (7-15) of the chessboard in various positions and then add their paths to the xml file that the program calls. For stereo vision the cameras should obviously be in their desired configuration before calibrating. 
- 
-===== Calibration Math ===== 
- 
-  * Since the cameras are not perfectly made, there are defects that can be approximated through a camera matrix, radial distortion, and tangential distortion. 
-  * The camera matrix is a 3x3 matrix that contains the focal length of the camera as well as the image center. This can be estimated by OpenCV or can be passed explicitly for more accurate results. 
-  * Radial distortion is the distortion of the image as it approaches the edges of the image. This is most present in fisheye lenses with very wide field of view. Since orthographic fisheye lenses approximate f = sin0 we can model this in the calibration software as a taylor polynomial of the sine function. 
-  * Tangential distortion is the distortion of the image caused by the lens and the sensor not being perfectly parallel. This can be further corrected by taking the outputs of the radial correction and plugging them in to the OpenCV given functions. 
-  * What the calibration essentially does is minimize the error of all the points on the chessboard from a normal configuration to the projected points after undistorting. This is done by guessing the coefficients of each distortion and improving the results slightly over many iterations. 
- 
-===== Using Calibrated Cameras ===== 
- 
-  * What the mono-calibration ultimately does is convert curved lines in the image into straight lines. This is most useful for finding shapes and lines in the image where it would be deformed too much in the original image. 
-  * What the stereo-calibration ultimately does is create a model that represents the locations and projections of both cameras in 3D space. This is most useful for estimating the distance of objects by plotting them within the stereo depth map. 
-  * Due to the very large field of view of fisheye lenses, object size near the edges of an image after undistortion become extremely large. Because of this, don't rely on object size in the vision system if you are referencing an undistorted image. 
-  * In addition, the quality of an image after undistortion degrades rapidly as you head outward. To account for this, you must also not trust coloration and quality of objects beyond 90 degree FOV. 
-  * Due to the vignetting (darkening) of the image near the edges of the image for the fisheye lenses, it is recommended to do a circular '​crop'​ of the image before sending it to the vision pipeline as the discoloration and artifacts near the edge of the image can interfere with the vision algorithms. Also, since the cameras have 185 degree FOV, cutting the last 5 degrees is a good tradeoff. 
-