Note: please also refer to the original PTAM.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Tutorial for calibrating the camera

Description: This tutorial explaines how to best calibrate a camera in order to use it with ethzasl_ptam

Tutorial Level: BEGINNER

Next Tutorial: using_ethzasl_ptam

Preparation

This tutorial assumes that you have a working camera streaming monochrome images on a ROS image topic. Ideally, the camera should have a lens with a wide field of view (more than 90°) and a global shutter. Smaller field of views might work, however, the ATAN camera model used in PTAM is not well suited for these type of lenses. Similary, cameras with rolling shutter do work to some extent, however, feature extraction and matching performance deterioates greatly with more motion. This will come aparent later on when using ethzasl_ptam to estimate the camera pose. When calibrating the camera - and working in general with ethzasl_ptam - ensure that there is sufficient light. As a rule of thumb, the camera shutter speed should always be lower than 5ms to avoid motion blur.

ATI Graphics Cards and OpenGL

Unfortunately, some ATI graphics card drivers are not compatible with OpenGL. You are affected by this inconvenience if you have an ATI graphics card and only see random graphics effects in the OpenGL window of the cameracalibrator while the node as such is running properly.

We suggest the following workaround: Do the camera calibration on a computer with an NVIDIA graphics card. Then, use the calibration parameters on your ATI machine and run ethzasl_ptam remotely as described in this tutorial.

Preparing the calibration pattern

In the source files of ptam you find a calibration pattern. Print it on white paper and fix it on a rigid and completely flat surface. Also, make sure that the surrounding of the pattern is as homogenuous in color as possible. Your working desk might be an optimal place.

The homogenuous surrounding is necessary because of a bug we still have to fix: the cameracalibrator extracts FAST corners in the image and tries to fit a checker board to these corners. If it finds too many FAST corners not belonging to a checkerboard, an error occurs during the fitting process.

A good calibration pattern setup may look like this:

sample_calibrationpattern_setup.jpg The camera calibration pattern should be on a homogenuous background.

Calibrating the camera

Edit the PtamFixParams.yaml file and set the parameters "ImageSizeX" "ImageSizeY" to your image resolution.

Edit the cameracalibrator.launch file to map the image to your image topic. Point the camera to the calibration pattern and only then start the cameracalibrator node:

roslaunch ptam cameracalibrator.launch

The cameracalibrator fires up and looks like this:

cam_calibrator.jpg

Now use the camera and "look" at the calibration pattern from different perspectives and hit "GrabFrame" each time you want to store an image of the pattern for the calibration. You recognize "good" images to store if the cameracalibrator could fit a blue pattern to parts of the checker board as shown in the above figure. If you shot around 10 pictures, press "Optimize" and wait until the calibration converged. For 90° FoV lenses the mean pixel error should be below 0.5, for 150° FoV lenses it should be below 0.3.

cam_calibrator_samples.jpg Image samples of a calibration procedure. Take around 10 shots.

cam_calibrator_calibrated.jpg Screen after hitting the "Optimize" button.

Note down the 5 numbers for the camera calibration and then hit "save" to exit the cameracalibrator. (If you started the cameracalibrator using rosrun ptam cameracalibrator image:=/[your image topic] then these 5 numbers will appear in the console and you can copy them.)

Open the file PtamFixParams.yaml in the ptam source files and copy paste the camera calibration values in the order of appearence

  • Cam_fx: first value (normalized focal length in x)
  • Cam_fy: second value (normalized focal length in y)
  • Cam_cx: third value (normalized camera center in x)
  • Cam_cy: fourth value (normalized camera center in y)
  • Cam_s: fifth value (normalized distortion factor, <1 for wide FoV)

Saving the file with the new calibration values concludes this tutorial.

Wiki: ethzasl_ptam/Tutorials/camera_calibration (last edited 2013-01-03 16:37:15 by GreyCardinaRus)