Download MATLAB source from calib_demo2.zip

This study concentrates on the Bouguet calibration toolbox routine
`project_points2.m`

which projects checkerboard world coordinates
to camera image coordinates in pixels. The differences between the reprojected
corner points and the original measured cornerpoints are the reprojection errors.

You should run script6.m to set-up the workspace variables. The Bouguet routines have been converted to scripts and simplified so that they can be run separately and published.

Let P be a point in 3D of coordinates **X** in the world reference frame
(stored in the matrix **X**)
The coordinate vector of P in the camera reference frame is: Xc = R*X + T
where R is the rotation matrix corresponding to the rotation vector om: `R = rodrigues(om);`

call x, y and z the 3 coordinates of Xc: x = Xc(1); y = Xc(2); z = Xc(3);

The pinehole projection coordinates of P is [a;b] where a=x/z and b=y/z.

call *r*^{2} = *a*^{2} + *b*^{2}.

The distorted point coordinates are: `xd = [xx; yy]`

where:

xx = a * (1 + kc(1)*r^2 + kc(2)*r^4 + kc(5)*r^6) + 2*kc(3)*a*b + kc(4)*(r^2 + 2*a^2); yy = b * (1 + kc(1)*r^2 + kc(2)*r^4 + kc(5)*r^6) + kc(3)*(r^2 + 2*b^2) + 2*kc(4)*a*b;

The left terms correspond to radial distortion (6th degree), the right terms correspond to tangential distortion

Finally, convertion into pixel coordinates: The final pixel coordinates vector xp=[xxp;yyp] where:

xxp = f(1)*(xx + alpha*yy) + c(1) yyp = f(2)*yy + c(2)