Translations of this page?:

How to calibrate the cameras


A calibration of the cameras is very important if you want to make full use of the stereo cameras. A well executed camera calibration can produce an accurate disparity image that brings depth information to the image and enable us to work with stereo processing. The disparity image is then used by some other applications, such as the qbo_stereo_selector node that detects close objects. Therefore, a badly executed calibration of the cameras can produce a malfunctioning of many nodes that uses.

The qbo_camera package contains the stereo_calibration node that you can use to calibrate your cameras. This tutorial will show you how to correctly calibrate your cameras using this node and how to check the quality of your disparity image.

1. Before launching the calibration node

1.1 Make sure you have your calibration pattern with you

The calibration pattern needed for this calibration is a 7×9 checkerboard in which the length of every square is 2,84cm (1.12''). This calibration pattern comes with the robot. You can also download it here.

1.2. Check your light conditions

For for a correct camera calibration, you must have proper light conditions in the room. Make sure that both cameras are not pointing directly to a light source (window, lamp, a bright reflection) and that the room has sufficient light.

1.3. Place your on top of a table

This is more a suggestion than a requisite. Placing a on top of a table puts it's cameras at the level of your shoulders if you are seated on a chair. This makes the procedure more comfortable, since you can easily show him the calibration pattern and at the same time press the keyboard that you will have on top of the table.

1.4. Connect a monitor, keyboard and mouse to

You must execute the stereo_calibration node from within the robot. For that you will need to connect as a desktop, by plugging a monitor, keyboard and a mouse.

2. Launch the stereo calibration node

There are two ways of launching the stereo calibration node:

- Access the Webi from within the robot and log in. The open the “Config Wizard” tab and click on the “Launch Stereo Camera Calibration” button.


- Open a terminal and execute:

 roslaunch qbo_camera qbo_cameras_stereo_calibration.launch

The stereo_calibration node executes 3 stages of calibration:

  1. Calibration of the left camera
  2. Calibration of the right camera
  3. Calibration of the stereo

For each stage, this node will require 9 images to be captured. So, 27 images will have to be captured in total, in the process of calibration. To capture an image, you can press any key on the keyboard (for example, the 'n' key).

3. Calibrate left and right cameras

3.1 Calibrate the left camera

After launching the stereo_calibration node, it will firstly execute the calibration of the left camera. For that, 9 images are needed to be captured.

You will immediately see two Display Windows on the top. On the left Display Window you will see the image of the camera to be calibrated (in this case, the left camera's image). The right Display Window will show the detected corners of the calibration pattern after an image capture. Make sure that the image you see on the left Display Window correspond to the correct camera.

Before capturing an image (by pressing any key on the keyboard), make sure that the calibration pattern is well visible. For good result, there are 3 great tips that you need to follow:

  1. Show the calibration pattern in the portrait orientation.
  2. Try to position the calibration pattern as close as possible to the camera without hiding any interior corner.
  3. Try changing the inclination and position of the calibration pattern as much as possible, i.e., avoid capturing two identical images.

If any of the interior corners of the calibration pattern is not visible in the image, the stereo_calibration will make you repeat the capture.

Good positioning of the calibration pattern:

Bad positioning of the calibration pattern:

After a successful capture of 9 images, the calibration_node will show you the result of the undistorted image on the left Display Window:

The undistorted image must eliminate the radial distortions of the original image. To verify this, you must see, in the undistorted image, only straight lines in the calibration pattern, while in the original image (raw image), the straight lines must present a soft bending due to the image distortion.

To continue to the next stage - calibration of the right camera - press “Enter” or press “r” to repeat the left calibration process.

3.2 Calibrate the right camera

The steps to calibrate the right camera are identical to the calibration of the left camera. Just make sure the image you see on the left Display Window corresponds to the right camera image. You can then proceed with its calibration, by correctly showing the calibration pattern and capturing the image pressing any key on the keyboard. After 9 successful captures, the node will show you the resultant undistorted image. You can click “Enter” to continue to the stereo calibration or “r” to repeat the right camera calibration process.

4. Calibrate the stereo

Stereo calibration implies capturing simultaneous images of both left and right cameras. So you have to be extra careful while showing the calibration pattern to make sure all inner corners are visible in both images at the same time. For that, it may be necessary to slightly move away the calibration pattern from the cameras. In this stage, four Display Windows will appear: 2 for the cameras' images and 2 for the camera's corner detections. Once again, press any key to capture. After 9 successful capture, you should see the result rectified images in the top Display Windows.

5. Submit the calibration

If you want to submit the calibration, i.e., make it permanent even if you reboot the robot, just press “Enter” when the rectified images are being shown. If you want to repeat your calibration, press 'r', and you will repeat the last calibration stage (stereo calibration). You can abort the calibration at any time by pressing Ctrl+C.

6. Check your calibration

The best way to check the calibration you just made is to view the disparity image. For that, execute in the console:

 rosrun image_view disparity_view image:=/stereo/disparity

You will immediately see the disparity image. In this viewer of the disparity image, hotter colors (red, yellow, etc.) correspond to closer points, while colder colors (violet, blue, etc.) correspond to farther points. The grey points correspond to points where the stereo could not compute their depths. You will always have grey points in the disparity image (specially on one side of the image and on the upper and lower parts), but the golden rule is: The lesser grey points you have, the better is the quality of the disparity image.

Here is an example of a good disparity image (left image) and bad disparity image (right image):

Good Disparity Image Bad Disparity Image

qbo_apps/ros_pack/qbo_camera/tutorials/calibrate_cameras.txt · Last modified: 2013/07/06 05:04 by mzi