Exercise 1
Exercise 1
Marc Pollefeys
Computer Science Department Prof. Luc Van Gool
HS 2012
Computer Vision
Exercise 1
Hand-out: 27-09-2012
Hand-in: 04-10-2012 13:00
Objective:
In this exercise you will calibrate your own camera. Two algorithms will be implemented:
the simple Direct Linear Transform algorithm and the Gold Standard algorithm.
As a preparatory step you have to make an image of a 3D calibration object. An
easy way to generate such an object is to stick two checkerboard patterns (http://
www.vision.caltech.edu/bouguetj/calib_doc/htmls/pattern.pdf) to two
orthogonal planes (e.g. walls in a room). An example is shown in Figure 1. Make sure
that the object fills almost the whole image to get a more precise calibration.
The calibration can be determined from 3D to 2D correspondences. To get the 3D coordi-
nates, you can simply put the origin of the coordinate system somewhere on the calibration
object. When taking multiple images, make sure to keep the coordinate systems consistent.
The code framework provides a function for clicking points in the image. For each clicked
image point you have to enter the corresponding 3D-coordinate.
Make sure you use the same camera with the same settings for ALL tasks!
The 2D coordinates x and the 3D coordinates X are homogeneous vectors.
P̂1
wi X̂i> 0> − xi X̂i>
P̂2 = 0 (1)
0> −wi X̂i> yi X̂i>
P̂3
• Factorize the camera matrix into the intrinsic matrix K, the rotation matrix R and the
camera center C.
where M = KR is the product of the intrinsic matrix and the camera rotation matrix and
C is the camera center. The matrix M can be decomposed with a RQ-decomposition.
The camera center C is the right null-vector of P.
• Visualize the hand-clicked points and the reprojection of the 3D points on the cali-
bration object obtained by using the computed camera matrix.
• What happens if you use the unnormalized points? Compare the intrinsic parameters
and the reprojection errors.
1.3 Gold Standard algorithm (30%)
The Gold Standard algorithm minimizes the geometric error ∑i d(xi , x̂i )2 where xi is the
measured (clicked) point and x̂i is the projected object point PXi . d(xi , x̂i ) is the Euclidean
distance between the 2D points given by xi and x̂i .
• Normalize the input points and run the DLT algorithm to get an initial camera matrix
P̃ for the optimization.
• Minimize the geometric error ∑i d(xi , x̂i )2 over the normalized camera matrix ~
P.
Check the MATLAB function fminsearch or lsqnonlin.
• Denormalize and factorize the camera matrix as in task 1.
• Visualize the hand-clicked points and the reprojection of the points on the calibration
object obtained by using the computed camera matrix.
1.5 Gold Standard algorithm with radial distortion estimation (+10% bonus)
During the optimization of P also the coefficients of the radial distortion introduced by the
lens can be estimated. A commonly used model for radial distortion is
xd x̃ 2 4 x̃
= L(r̃ ) = (1 + κ1 r̃ + κ2 r̃ ) (3)
yd ỹ ỹ
where ( x̃, ỹ) is the ideal pinhole projection of a 3D point X
x
y = [R|−RC]X
z
x̃ = x/z
ỹ = y/z
and ( xd , yd ) is the position after radial distortion. To compute the actual position in the
image, the pposition ( xd , yd , 1) has to be multiplied with the intrinsic matrix K. r̃ is the radial
distance x̃2 + ỹ2 from the center of radial distortion.
The center of the radial distortion can be assumed to be the same as the principal point
( p x , p y ).
Redo task 1.3, but this time jointly estimate the projection matrix P and the distortion coef-
ficients κ1 and κ2 .
Hand in:
Write a short report explaining the main steps of your implementation. Compare the re-
sults obtained by using the DLT method with and without data normalization, the Gold
Standard, the Gold Standard including radial distortion (bonus) and result obtained by
using Bouguet’s toolbox. Discuss the intrinsic parameters and the average reprojection er-
rors. The report should contain images showing the clicked 2D points before calibration
and the reprojected 3D points obtained by using the calibration parameters. Send the re-
port together with your source code to [email protected]. Additionally, include the
hand-clicked 3D to 2D correspondences used for calibration stored as a Matlab .mat-File
and the image of your calibration object.
References:
[1] http://www.vision.caltech.edu/bouguetj/calib_doc/index.html