Calibrating your Kinect (OpenNI backend)


New since RGBDemo v0.5.0: if you are using the OpenNI backend, then the calibration parameters will be determined automatically.

Note: you might first want to read the previous section to get an overview of the calibration system.

OpenNI comes with a predefined calibration stored in the firmware that can directly output aligned depth and color images with a virtual constant focal length. Most applications will be happy with this calibration and do not require any additional step. However, some computer vision applications such as robotics might need a more accurate calibration. RGBDemo comes with two utilities to refine the predefined calibration.

Using calibrate-openni-intrinsics

This program takes as an input a set of images with a checkerboard, as output by rgbd-viewer. It also takes the initial calibration file, which can be created using File/Save calibration file in rgbd-viewer.

Then here is a typical example of usage:

./calibrate-openni-intrinsics --pattern-size 0.025 grab1/SERIAL calibration-SERIAL.yml

where SERIAL is the serial number of your camera.

The openni_calibration.yml file should contain the refined parameters.

Calibrating your Kinect (libfreenect backend)


Note: this is only necessary if you want to use the libfreenect backend.

A sample calibration file is provided in data/kinect_calibration.yml. However, you should be able to get a more accurate mapping by estimating new parameters for each Kinect. Below is the procedure I follow.

1. Build a calibration pattern as shown in KinectCalibrationTheory. You can use the Chessboard_A4.pdf or Chessboard_A3.pdf file in the data/ directory for this. I recommend printing the chessboard on a sheet of paper and glue it on a peace of carton. It is not necessary anymore to cut the carton around the paper.

2. Grab some images of your chessboard using the viewer (File / Grab frame or Ctrl-G). WARNING: you need to grab images in Dual IR/RGB more (enable it in the Capture menu). By default it will save them into directories grab1/SERIAL/view????. These directories contain the raw files, raw/color.png, raw/depth.raw and raw/intensity.raw that corresponds to the color image, the depth image (in meters), and the IR image normalized to grayscale. SERIAL should be the serial number of your camera.

To get an optimal calibration, grabbed images should ensure the following:

  • Cover as most image area as possible. Especially check for coverage of the image corners.
  • Try to get the chessboard as close as possible to the camera to get better precision.
  • For depth calibration, you will need some images with IR and depth. But for stereo calibration, the depth information is not required, so feel free to cover the IR projector and get very close to the camera to better estimate IR intrinsics and stereo parameters. The calibration algorithm will automatically determine which grabbed images can be used for depth calibration.
  • Move the chessboard with various angles.
  • I usually grab a set of 30 images to average the errors.
  • Typical reprojection error is < 1 pixel. If you get significantly higher values, it means the calibration probably failed.

3. Run the calibration program:

build/bin/calibrate-kinect-ir --pattern-size 0.025 --input grab1/SERIAL

The pattern size correspond to the size in meters of one chessboard square. It should be 0.025 (25mm) for the A4 model.

This will generate the calibration-SERIAL.yml file storing the parameters for the viewer, and two files calibration_rgb.yaml and calibration_depth.yaml for ROS compatibility.

Calibrating with a projector