Working with ROS camera calibration

Like all sensors, cameras also need calibration for correcting the distortions in the camera images due to the camera's internal parameters and for finding the world coordinates from the camera coordinates.

The primary parameters that cause image distortions are radial distortions and tangential distortions. Using camera calibration algorithm, we can model these parameters and also calculate the real world coordinates from the camera coordinates by computing the camera calibration matrix, which contains the focal distance and the principle points.

Camera calibration can be done using a classic black-white chessboard, symmetrical circle pattern, or asymmetrical circle pattern. According to each different pattern, we use different equations to get the calibration parameters. Using the calibration tools, we detect the patterns and each detected pattern is taken as a new equation. When the calibration tool gets enough detected patterns, it can compute the final parameters for the camera.

ROS provides a package named camera_calibration (http://wiki.ros.org/camera_calibration/Tutorials/MonocularCalibration) to do camera calibration, which is a part of the image pipeline stack. We can calibrate monocular, stereo, and even 3D sensors such as Kinect and Asus Xtion pro.

The first thing we have to do before calibration is download the check board
pattern mentioned in the ROS Wiki page, and print it and paste it onto a card board. This is the pattern we are going to use for calibration. This check board has 8x6 with 108mm squares.

Run the usb_cam launch file to start the camera driver. We are going to run the camera calibration node of ROS using the raw image from the /usb_cam/image_raw topic. Following command will run the calibration node with the necessary parameters:

    $ rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.108 image:=/usb_cam/image_raw camera:=/usb_cam  

A calibration window will pop up, and when we show the calibration pattern to the camera, and the detection made, is seen in the following screenshot:

Figure 3: ROS camera calibration

Move the calibration pattern in X direction and Y direction. If the calibrator node gets a sufficient amount of samples, a calibration button will get active on the window. When we press the CALIBRATE button, it will compute the camera parameters using these samples. It will take some time for calculation. After computation, two buttons, SAVE and COMMIT, will become active inside the window, which is shown in the following image. If we press the SAVE button, it will save the calibration parameters to a file in the /tmp folder. If we press the COMMIT button, it will save them to ./ros/camera_info/head_camera.yaml.

Figure 4 : Generating camera calibration file

Restart the camera driver and we will see the YAML calibration file loaded along with the driver. The calibration file that we generated will look as follows:

image_width: 640 
image_height: 480 
camera_name: head_camera 
camera_matrix: 
  rows: 3 
  cols: 3 
  data: [707.1953043273086, 0, 346.4560078627374, 0, 709.5783421541863, 240.0112155124814, 0, 0, 1] 
distortion_model: plumb_bob 
distortion_coefficients: 
  rows: 1 
  cols: 5 
  data: [0.1779688561999974, -0.9681558538432319, 0.004497434720139909, 0.0106588921249554, 0] 
rectification_matrix: 
  rows: 3 
  cols: 3 
  data: [1, 0, 0, 0, 1, 0, 0, 0, 1] 
projection_matrix: 
  rows: 3 
  cols: 4 
  data: [697.5267333984375, 0, 353.9677879190494, 0, 0, 714.7203979492188, 240.6829465337159, 0, 0, 0, 1, 0] 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.117.56