Wednesday, February 10, 2010

Activity 6: Camera Calibration

Camera calibration allows us to obtain the camera properties that relates the image coordinates to the real world coordinates. The process results in a possible recovery of the principal point (Xi, Yi) in the image plane from the object coordinates (Xo, Yo, Zo) and vice - versa. Note that the image points are space points in the image plane and are therefore in 2D while the object or world points are space points in the real world and are in 3D. Being able to correctly allows us to model the physical processes involved in the geometric aspects of image formation allows us to[2]:

1. Determine 3D scene structures
2. Develop stereo or multiple camera systems for range measurement
3. Identify and correct image distortions


In this activity, we utilize camera calibration techniques to two set-ups namely (i) using a folded checkerboard (image in 3D) and (ii) using a flat checkerboard (image in 2D). The former will be done manually while the latter will use the camera calibration toolbox available for Matlab users.


I. Using a folded checkerboard

Figure 1. An image of the folded Tsai board (in 3D) taken inside the Instrumentation Physics Laboratory.

The camera properties are stored in the matrix containing the
a's and it can be solved by using the image coordinates (Xi, Yi) and object coordinates (Xo, Yo, Zo).



The equation can be simplified to:

where Q is the 2 x 11 matrix on the left hand side of the above equation and p are the image coordinates. Note that more than 11 sample points are needed in order for the calibration to be successful.

Figure 2. Reconstruction of the Tsai board with the 15 points used in the calibration.


Shown in Figure 2 are the points chosen(small filled rectangles in red) superimposed in the checkerboard. The green square in the center represents an edge. The corresponding image coordinates of the chosen points is presented in Table 1 below.

Table 1. Real world points (Xo, Yo, Zo) and corresponding Image points (Xi, Yi)

The concept of the activity seems easy but actually the implementation part can be very tricky. You need to carefully track the corresponding Xo, Yo and Zo values of the points you have selected. Manual calibration can be frustrating sometimes since once you make an error in clicking the chosen points, you have to repeat the whole procedure.

Tips:

1. Choose points in the different planes. In the start, I encountered an error which says that the outputs for the variable a are NaN. I realized that this happened because I chose all the points to be in the xy plane.

2. Do not choose the same point again. Errors will come out when you accidentally select a point that you have previously chosen.



II. Using the Matlab Camera Calibration Toolbox

The camera calibration toolbox for Matlab can easily be downloaded from this link[1]:
http://www.vision.caltech.edu/bouguetj/calib_doc/

It provides a detailed outline and demonstration with a complete documentation on camera calibration. In this part of the activity, we used a total of 20 images of a planar checkerboard.

Figure 3. Image of the Tsai grid in 2D.

Figure 4. Sample reconstruction using the camera calibration toolbox in Matlab.

Figure 5. Reprojection error for the images
Figure 6. Extrinsic parameters in camera-centered view



Calibration results after optimization (with uncertainties):

Focal Length: fc = [ 910.33832 921.76778 ] [ 8.77607 10.10174 ]
Principal point: cc = [ 132.31855 -11.31912 ] [ 0.00000 0.00000 ]
Skew: alpha_c = [ 0.00000 ] [ 0.00000 ]
Distortion: kc = [ -0.08941 0.14265 -0.04032 -0.03135 0.00000 ]
Pixel error*: err = [ 1.25516 1.10094 ]

*The pixel error value we obtained is actually small considering that the size of our image is in Megabytes.



This activity may seem easy since everything is available in the Matlab toolbox. But actually, it was also quite difficult since the procedure to assign the endpoints is done manually. This leads to errors especially in images where the edges are not that resolved. Like the manual procedure, the camera calibration toolbox can also be frustrating since once you make an error in assigning the endpoints, you have to repeat the whole procedure.


I give myself a grade of 9.5 for this camera calibration activity.


References:

[1]. Camera Calibration Toolbox available at: http://www.vision.caltech.edu/bouguetj/calib_doc/.
[2]. M. Soriano. "A Geometric Model for 3D Imaging "
Applied Physics Lecture Notes 2010.



For teaching concerns please visit: https://sites.google.com/site/alongjas/

1 comment:

  1. Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!

    ReplyDelete