Vision Group Logo

Calibration


This webpage aims to guide you through the process of calibrating a camera using the Tsai Calibration software, with a view to using TsaiCal C++ Class in a multiple camera application.


Okay, from an image, identify a set of (say 50) points whose corresponding points in the real world are known.

Image for calibration of soccer game in sports hall Graphic of sports hall floor markings from above
Image for calibration of soccer game in sports hall. Graphic of sports hall floor markings from above

Now create a file 'cam_cd.dat' of x y z u v correspondences.

0 32000 0 66 53
2450 30470 0 88 56
2450 24400 0 68 74
2450 22840 0 61 80
2450 19810 0 46 94
2450 16780 0 26 113
2450 15220 0 13 124
3200 27430 0 91 63
3200 24860 0 81 72
3200 22380 0 70 82
3200 19810 0 58 94
3200 17240 0 43 109
3200 14760 0 24 129
7130 30470 0 145 55
7130 27430 0 141 64
7130 24860 0 137 73
7130 22380 0 133 81
7130 17240 0 119 112
7130 14760 0 112 127
7130 12190 0 99 155
7130 9620 0 83 192
7130 7600 0 64 235
7130 7140 0 59 247
11130 30470 0 194 55
11130 27430 0 195 63
11130 24860 0 197 73
11130 22380 0 199 81
11130 19810 0 200 93
11130 17240 0 203 111
11130 14760 0 206 127
11130 12190 0 211 154
11130 9620 0 217 193
11130 7600 0 224 236
11130 7140 0 226 248
15050 27430 0 248 62
15050 24860 0 254 70
15050 22380 0 262 81
15050 19810 0 271 93
15050 17240 0 283 108
15050 14760 0 297 127
15050 12190 0 316 153
15050 9620 0 343 190
15800 30470 0 252 55
15800 27430 0 258 62
15800 24400 0 267 72
15800 22840 0 273 78
15800 19810 0 285 92
15800 16780 0 300 111
15800 15220 0 311 122 
15800 12190 0 336 153
18000 32000 0 276 52

Next, we need to take this 'calibration data' and calculate the camera parameters. Having downloaded the Tsai Calibration Code, and compiled this, we are ready.

For fully optimised camera calibration, we use the routine 'ccal_fo', which calibrates a camera given a set of many 7 > x > 500 correspondences of the form Xw Yw Zw u v with Zw = 0 if coplanar data used. All world obs in [mm], image u,v in pixels.

ccal_fo cam_cd.dat > cam_cp.dat
ccal_fo cam_cd.dat >& cam.calinfo

Now we have two files, 'cam_cp.dat' containing the 12 camera parameters, and 'cam.calinfo' containing details about the calibration. viz.

cam_cp.dat cam.calinfo
 5.7600000000e+02
 5.7600000000e+02
 2.3000000000e-02
 2.3000000000e-02
 2.3000000000e-02
 2.3000000000e-02
 1.7904325577e+02
 1.0016861245e+02
 1.0000000000e+00
 8.7777901191e+00
 2.7367337113e-03
-1.0080366213e+04
 5.8119331472e+03
 2.0953966937e+03
 1.8850872153e+00
 8.9522740451e-03
-6.9566269979e-03
 0.0000000000e+00
 0.0000000000e+00
Coplanar calibration (full optimization) 

camera type: Photometrics Star I

data file: cambal1_cd.dat  (51 points)

       f = 8.777790  [mm]

       kappa1 = 2.736734e-03  [1/mm^2]

       Tx = -10080.366213,  Ty = 5811.933147,  Tz = 2095.396694  [mm]

       Rx = 108.007541,  Ry = 0.512928,  Rz = -0.398585  [deg]

       R
        0.999936   0.006363  -0.009383
       -0.006956  -0.309194  -0.950974
       -0.008952   0.950978  -0.309130

       sx = 1.000000
       Cx = 179.043256,  Cy = 100.168612  [pixels]

       Tz / f = 238.715743

       distorted image plane error:
         mean = 0.880966,  stddev = 0.622206,  max = 3.292051  [pix],  sse = 58.938184  [pix^2]

       undistorted image plane error:
         mean = 0.907604,  stddev = 0.629328,  max = 3.321848  [pix],  sse = 61.813687  [pix^2]

       object space error:
         mean = 49.155172,  stddev = 43.147031,  max = 239.972542  [mm],  sse = 216311.090053  [mm^2]

       normalized calibration error:  2.223167

 5.7600000000e+02
 5.7600000000e+02
 2.3000000000e-02
 2.3000000000e-02
 2.3000000000e-02
 2.3000000000e-02
 1.7904325577e+02
 1.0016861245e+02
 1.0000000000e+00
 8.7777901191e+00
 2.7367337113e-03
-1.0080366213e+04
 5.8119331472e+03
 2.0953966937e+03
 1.8850872153e+00
 8.9522740451e-03
-6.9566269979e-03
 0.0000000000e+00
 0.0000000000e+00

This file (cam_cp.dat) can now be used by the methods in Tsai's Calibration C software, giving a calibrated camera which can be used to project points from image to world and world to image in a tracking application or the like. (see wc2ic.c for an example program).

Tsai's C code only allows one camera at a time, so I've converted the useful code to C++, allowing use of several cameras at once in a tracking application.

The class 'TsaiCal' contains methods to convert from world to image coordinates. The constructor needs Camera Parameters in the format obtained from Tsai's Calibration C software. This class allows the use of several calibrated cameras within a single application, although Tsai's Calibration C software will need to be used in advance to work out the Camera Parameters from calibration data of correspondences between points (either coplanar calibration or non-coplanar). See wc2ic.cpp for a C++ style wc2ic.c program. Files for the TsaiCal C++ Class can be downloaded below:

For details of Tsai method, information can be found on Reg Wilson's site. From Horn's MIT page, the following paper may also be useful: Tsai's camera calibration revisited.


Chris Needham - Leeds Vision Group, School of Computing. 07-Feb-2003.