*Geometric camera calibration*, also referred to as *camera
resectioning*, estimates the parameters of a lens and image sensor of an
image or video camera. You can use these parameters to correct for lens distortion, measure
the size of an object in world units, or determine the location of the camera in the scene.
These tasks are used in applications such as machine vision to detect and measure objects.
They are also used in robotics, for navigation systems, and 3-D scene reconstruction.

Examples of what you can do after calibrating your camera:

Camera parameters include intrinsics, extrinsics, and distortion coefficients. To estimate the camera parameters, you need to have 3-D world points and their corresponding 2-D image points. You can get these correspondences using multiple images of a calibration pattern, such as a checkerboard. Using the correspondences, you can solve for the camera parameters. After you calibrate a camera, to evaluate the accuracy of the estimated parameters, you can:

Plot the relative locations of the camera and the calibration pattern

Calculate the reprojection errors.

Calculate the parameter estimation errors.

Use the **Camera Calibrator** to perform camera calibration
and evaluate the accuracy of the estimated parameters.

The Computer Vision Toolbox™ calibration algorithm uses the camera model proposed by Jean-Yves Bouguet [3]. The model includes:

The pinhole camera model does not account for lens distortion because an ideal pinhole camera does not have a lens. To accurately represent a real camera, the full camera model used by the algorithm includes the radial and tangential lens distortion.

A pinhole camera is a simple camera without a lens and with a single small aperture. Light rays pass through the aperture and project an inverted image on the opposite side of the camera. Think of the virtual image plane as being in front of the camera and containing the upright image of the scene.

The pinhole camera parameters are represented in a 4-by-3 matrix called the
*camera matrix*. This matrix maps the 3-D world scene into the
image plane. The calibration algorithm calculates the camera matrix using the extrinsic
and intrinsic parameters. The extrinsic parameters represent the location of the camera
in the 3-D scene. The intrinsic parameters represent the optical center and focal length
of the camera.

The world points are transformed to camera coordinates using the extrinsics parameters. The camera coordinates are mapped into the image plane using the intrinsics parameters.

The calibration algorithm calculates the camera matrix using the extrinsic and intrinsic parameters. The extrinsic parameters represent a rigid transformation from 3-D world coordinate system to the 3-D camera’s coordinate system. The intrinsic parameters represent a projective transformation from the 3-D camera’s coordinates into the 2-D image coordinates.

The extrinsic parameters consist of a rotation, *R*, and a
translation, *t*. The origin of the camera’s coordinate system is
at its optical center and its *x-* and *y-*axis
define the image plane.

The intrinsic parameters include the focal length, the optical center, also known
as the *principal point*, and the skew coefficient. The camera
intrinsic matrix, *K*, is defined as:

$$\left[\begin{array}{ccc}{f}_{x}& 0& 0\\ s& {f}_{y}& 0\\ {c}_{x}& {c}_{y}& 1\end{array}\right]$$

The pixel skew is defined as:

$$\left[\begin{array}{cc}{c}_{x}& {c}_{y}\end{array}\right]$$ — Optical center (the principal point), in pixels. |

$$\left(\begin{array}{cc}{f}_{x},& {f}_{y}\end{array}\right)$$ — Focal length in pixels. $${f}_{x}=F/{p}_{x}$$ $${f}_{y}=F/{p}_{y}$$ $$F$$ — Focal length in world units, typically expressed in millimeters. $$\left(\begin{array}{cc}{p}_{x},& {p}_{y}\end{array}\right)$$ — Size of the pixel in world units. |

$$s$$ — Skew coefficient, which is non-zero if the image
axes are not perpendicular. $$s={f}_{x}\mathrm{tan}\alpha $$ |

The camera matrix does not account for lens distortion because an ideal pinhole camera does not have a lens. To accurately represent a real camera, the camera model includes the radial and tangential lens distortion.

Radial distortion occurs when light rays bend more near the edges of a lens than they do at its optical center. The smaller the lens, the greater the distortion.

The radial distortion
coefficients model this type of distortion. The distorted points are
denoted as (*x*_{distorted}, *y*_{distorted}):

*x*_{distorted} = *x*(1
+ *k*_{1}**r*^{2} + *k*_{2}**r*^{4} + *k*_{3}**r*^{6})

*y*_{distorted}= *y*(1
+ *k*_{1}**r*^{2} + *k*_{2}**r*^{4} + *k*_{3}**r*^{6})

*x*,*y*— Undistorted pixel locations.*x*and*y*are in normalized image coordinates. Normalized image coordinates are calculated from pixel coordinates by translating to the optical center and dividing by the focal length in pixels. Thus,*x*and*y*are dimensionless.*k*_{1},*k*_{2}, and*k*_{3}— Radial distortion coefficients of the lens.*r*^{2}:*x*^{2}+*y*^{2}

Typically, two coefficients are sufficient for calibration.
For severe distortion, such as in wide-angle lenses, you can select
3 coefficients to include *k*_{3}.

Tangential distortion occurs when the lens and the image plane are not parallel. The tangential distortion coefficients model this type of distortion.

The distorted
points are denoted as (*x*_{distorted}, *y*_{distorted}):

*x*_{distorted} = *x* +
[2 * *p*_{1} * *x* * *y* + *p*_{2} *
(*r*^{2} + 2 * *x*^{2})]

*y*_{distorted} = *y* +
[*p*_{1} * (*r*^{2} +
2 **y*^{2}) + 2 * *p*_{2} * *x* * *y*]

*x*,*y*— Undistorted pixel locations.*x*and*y*are in normalized image coordinates. Normalized image coordinates are calculated from pixel coordinates by translating to the optical center and dividing by the focal length in pixels. Thus,*x*and*y*are dimensionless.*p*_{1}and*p*_{2}— Tangential distortion coefficients of the lens.*r*^{2}:*x*^{2}+*y*^{2}

[1] Zhang, Z. “A Flexible New Technique for Camera
Calibration.” *IEEE Transactions on Pattern Analysis and Machine
Intelligence*. Vol. 22, No. 11, 2000, pp. 1330–1334.

[2] Heikkila, J., and O. Silven. “A Four-step Camera
Calibration Procedure with Implicit Image Correction.” *IEEE
International Conference on Computer Vision and Pattern
Recognition*.1997.

[3] Bouguet, J. Y. “Camera Calibration Toolbox for Matlab.” Computational Vision at the California Institute of Technology. Camera Calibration Toolbox for MATLAB.

[4] Bradski, G., and A. Kaehler. *Learning OpenCV:
Computer Vision with the OpenCV Library*. Sebastopol, CA: O'Reilly,
2008.

Camera Calibrator | Single Camera Calibrator App