Camera Calibration Toolbox for Matlab
Intrinsic parameters (camera model):
The internal
camera model is very similar to that used by Heikkilä and Silven at the University of Oulu in Finland. Visit
their online calibration
page, and their publication page. We
specifically recommend their CVPR'97 paper: A
Fourstep Camera Calibration Procedure with Implicit Image
Correction.
The list of internal parameters:
Definition of the intrinsic parameters:
Let P be a point in space of coordinate vector XX_{c}
= [X_{c};Y_{c};Z_{c}] in the camera reference
frame.
Let us project now that point on the image plane according to the intrinsic
parameters (fc,cc,alpha_c,kc).
Let x_{n} be the normalized (pinhole) image projection:
Let r^{2} = x^{2} + y^{2}.
After including lens distortion, the new normalized point coordinate
x_{d}
is defined as follows:
where dx is the tangential distortion vector:
Therefore, the 5vector kc contains both radial and tangential distortion coefficients (observe that the coefficient of 6^{th} order radial distortion term is the fifth entry of the vector kc).
It is worth noticing that this distortion model was first introduced
by Brown in 1966 and called "Plumb Bob" model (radial polynomial +
"thin prism" ). The tangential distortion is due to "decentering", or imperfect centering of the lens components and other manufacturing defects in a compound lens. For more details, refer to Brown's original publications
listed in the reference page.
Once distortion is applied, the final pixel coordinates x_pixel = [x_{p};y_{p}]
of the projection of P on the image plane is:
Important Convention: Pixel coordinates are defined such that [0;0] is the
center of the upper left pixel of the image. As a result,
[nx1;0] is center of the upper right corner pixel, [0;ny1] is
the center of the lower left corner pixel and [nx1;ny1] is the center of the lower right
corner pixel where nx and ny are the width and height of
the image (for the images of the first example, nx=640 and
ny=480). One matlab function provided in the toolbox computes
that direct pixel projection map. This function is
project_points2.m. This function takes in the 3D coordinates of
a set of points in space (in world reference frame or camera reference
frame) and the intrinsic camera parameters
(fc,cc,kc,alpha_c), and returns the pixel
projections of the points on the image plane. See the information
given in the function.
The inverse mapping:
The inverse
problem of computing the normalized image projection vector
x_{n} from the pixel coordinate x_pixel is very
useful in most machine vision applications. However, because of the high degree distortion model, there exists no general algebraic expression for this inverse map (also called normalization). In
the toolbox however, a numerical implementation of inverse mapping is provided in the form of a function:
normalize.m. Here is the way the function should be called:
x_{n} = normalize(x_pixel,fc,cc,kc,alpha_c). In that
syntax, x_pixel and x_{n} may consist of more
than one point coordinates. For an example of call, see the matlab
function compute_extrinsic_init.m.
Reduced camera models:
Currently manufactured cameras do not always justify this very general optical model. For example, it now customary to assume rectangular pixels, and thus assume zero skew (alpha_c=0). It is in fact a default setting of the toolbox (the skew coefficient not being estimated). Furthermore, the very generic (6th order radial + tangential) distortion model is often not considered completely. For standard field of views (non wideangle cameras), it is often not necessary (and not recommended) to push the radial component of distortion model beyond the 4th order (i.e. keeping kc(5)=0). This is also a default setting of the toolbox. In addition, the tangential component of distortion can often be discarded (justified by the fact that most lenses currently manufactured do not have imperfection in centering). The 4th order symmetric radial distortion with no tangential component (the last three component of kc are set to zero) is actually the distortion model used by Zhang. Another very common distortion model for good optical systems or narrow field of view lenses is the second order symmetric radial distortion model. In that model, only the first component of the vector kc is estimated, while the other four are set to zero. This model is also commonly used when a few images are used for calibration (too little data to estimate a more complex model). Aside from distortions and skew, other model reductions are possible. For example, when only a few images are used for calibration (e.g. one, two or three images) the principal point cc is often very difficult to estimate reliably . It is known to be one of the most difficult part of the native perspective projection model to estimate (ignoring lens distortions). If this is the case, it is sometimes better (and recommended) to set the principal point at the center of the image (cc = [(nx1)/2;(ny1)/2]) and not estimate it further. Finally, in few rare instances, it may be necessary to reject the aspect ratio fc(2)/fc(1) from the estimation. Although this final model reduction step is possible with the toolbox, it is generally not recommended as the aspect ratio is often 'easy' to estimate very reliably. For more information on how to perform model selection with the toolbox, visit the page describing the first calibration example.Correspondence with Heikkilä's notation:
In the
original Heikkilä's paper, the internal
parameters appear with slightly different names. The following table
gives the correspondence between the two notation schemes:






















Correspondence with Reg Willson's notation:
In his original implementation
of the Tsai camera calibration algorithm, Reg
Willson uses a different notation for the camera parameters. The following
table gives the correspondence between the two notation schemes:












Willson uses a first order radial distortion model (with an additional
constant kappa1) that does not have an easy closedform corespondence
with our distortion model (encoded with the coefficients
kc(1),...,kc(5)).
However, we included in the toolbox a function called willson_convert
that converts the entire set of Willson's parameters into our parameters
(including distortion). This function is called in another function willson_read
that directly loads in a calibration result file generated by Willson's
code and computes the set parameters (intrinsic and extrinsic) following
our notation (to use that function, first set the matlab variable
calib_file
to the name of the original willson calibration file).
A few extra comments on Willson's model:
Extrinsic parameters:
Definition of the extrinsic parameters:
Consider the calibration grid #i (attached to the ith
calibration image), and concentrate on the camera reference frame attahed
to that grid.
Without loss of generality, take i = 1. The following figure
shows the reference frame (O,X,Y,Z) attached to that calibration
gid.
Let P be a point space of coordinate vector XX = [X;Y;Z]
in the grid reference frame (reference frame shown on the previous figure).
Let XX_{c} = [X_{c};Y_{c};Z_{c}]
be the coordinate vector of P in the camera reference frame.
Then XX and XX_{c} are related to each other
through the following rigid motion equation:
XX_{c} = Rc_1 * XX + Tc_1
In particular, the translation vector Tc_1 is the coordinate
vector of the origin of the grid pattern (O) in the camera reference
frame, and the thrid column of the matrix Rc_1 is the surface normal
vector of the plane containing the planar grid in the camera reference
frame.
The same relation holds for the remaining extrinsic parameters (Rc_2,Tc_2),
(Rc_3,Tc_3), ... , (Rc_20,Tc_20).
Once the coordinates of a point is expressed in the camera reference
frame, it may be projected on the image plane using the intrinsic camera
parameters.
The vectors omc_1, omc_1, ... , omc_20 are the
rotation vectors associated to the rotation matrices Rc_1, Rc_1,
... , Rc_20. The two are related through the rodrigues formula.
For example, Rc_1 = rodrigues(omc_1).
Similarly to the intrinsic parameters, the uncertainties attached to the estimates of the extrinsic parameters omc_i, Tc_i (i=1,...,n_ima) are also computed by the toolbox. Those uncertainties are stored in the vectors omc_error_1,..., omc_error_20, Tc_error_1,..., Tc_error_20 (assuming n_ima = 20) and represent approximately three times the standard deviations of the errors of estimation.