Algorithm Search⌘K

Problemintro

Camera calibration

Also called camera resectioning, geometric camera calibration.

Estimate the intrinsic, extrinsic and distortion parameters of a camera from images of points whose 3D positions or structure are known.

Camera calibration is the problem of finding the numbers that describe how a camera forms its image: the intrinsic matrix KK, the lens distortion, and, for each image, the pose given by the extrinsic parameters RR and tt. The input is images of a target whose 3D geometry is known, such as a box with marks, a flat checkerboard or a set of measured points. Among the close pages, this page states the problem and compares the methods. DLT resectioning estimates a general 3×43 \times 4 matrix PP from a 3D target, with no distortion. Camera matrix decomposition splits such a PP into KK, RR and tt. Zhang's method uses several views of a plane. Tsai's method uses a constraint that radial distortion does not affect.

In plain words

A camera turns 3D points into pixels by a fixed rule. The rule depends on the focal length, where the optical axis meets the sensor, how the lens bends straight lines, and where the camera stands. Calibration finds these numbers. You show the camera an object whose shape you know exactly, such as a printed checkerboard, and take some photos. You find the corners in each photo. Then you search for the numbers that make the rule send each known corner as close as possible to where it shows in the photo. After this, you can turn any pixel into a ray in 3D, remove the lens bending, and measure real sizes and distances.

Definition

The usual camera model is a pinhole with distortion. A world point XX goes to camera coordinates Xc=RX+tX_c = R X + t, then to the normalized image point xn=(Xc/Zc,Yc/Zc)x_n = (X_c / Z_c, Y_c / Z_c), then through a distortion map xd=Dk(xn)x_d = D_k(x_n) with parameters kk, and finally to the pixel

u=K(xd1),K=(fxscx0fycy001).u = K \begin{pmatrix} x_d \\ 1 \end{pmatrix}, \qquad K = \begin{pmatrix} f_x & s & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \end{pmatrix}.

Write π(K,k,R,t;X)\pi(K, k, R, t; X) for this map. The axes of the camera are XX to the right, YY down and ZZ forward, and the pixel center of the top left pixel is (0,0)(0, 0).

Input. NN images. In image jj, the target points XijX_{ij}, with known 3D coordinates in the frame of the target, and their measured pixels uiju_{ij}, for i=1,…,nji = 1, \dots, n_j.

Output. The intrinsics KK, the distortion parameters kk, and a pose (Rj,tj)(R_j, t_j) for each image.

Criterion. Under independent Gaussian pixel noise with the same variance, the maximum likelihood estimate minimizes the total reprojection error

E=∑j=1N∑i=1nj∥uij−π(K,k,Rj,tj;Xij)∥2.E = \sum_{j=1}^{N} \sum_{i=1}^{n_j} \big\| u_{ij} - \pi(K, k, R_j, t_j; X_{ij}) \big\|^2.

This is a nonlinear least squares problem. All the methods below either minimize EE directly from a starting guess, or give such a starting guess in closed form.

Variants

  • By target. A 3D target with points not on one plane (the classic photogrammetry setup); a planar target, such as a checkerboard or a grid of ArUco or AprilTag marks; a 1D target, such as points on a stick moved about a fixed point; or no target at all, which is self-calibration from the images of a rigid scene. Calibration from the vanishing points of three orthogonal directions is a special case with scene structure instead of a target.
  • By what is known. Intrinsics only, with the poses as nuisance parameters; intrinsics and the pose of one chosen view; or only the pose, with KK known, which is the perspective-n-point problem.
  • By lens model. A pure pinhole; a pinhole with the Brown-Conrady radial and tangential distortion; a fisheye model for wide lenses; or a generalized camera that gives each pixel its own ray.
  • By number of cameras. One camera, or several cameras with fixed relative poses, as in stereo camera calibration.
  • By the constraints on KK. General five parameter KK; zero skew; square pixels (fx=fyf_x = f_y); or a known principal point.

Examples

A direct check. Take a camera with zero skew, square pixels, f=800f = 800 unknown and principal point (320,240)(320, 240) known, and no distortion. A point at (0.5,0,2)(0.5, 0, 2) in camera coordinates shows at u=520u = 520. Then u−cx=f⋅0.5/2u - c_x = f \cdot 0.5 / 2, so f=200⋅4=800f = 200 \cdot 4 = 800. Real calibration does not know the camera coordinates of the point, so it must find the pose at the same time, and that makes the problem nonlinear.

Counting for a checkerboard. A board with 9×6=549 \times 6 = 54 inner corners, seen in N=10N = 10 images, gives 2⋅54⋅10=10802 \cdot 54 \cdot 10 = 1080 equations. The unknowns are 5 intrinsics, 2 radial distortion terms and 6 pose parameters per image, so 5+2+60=675 + 2 + 60 = 67 unknowns. The problem is strongly overdetermined, which averages out the corner noise.

Counting for a 3D target. A general 3×43 \times 4 camera matrix has 11 degrees of freedom, so 6 points in general position are enough for the linear method; see the worked example on DLT resectioning.

Known algorithms

method target start distortion page
DLT, decomposition, then geometric fit 3D, not coplanar closed form, from ≥6\ge 6 points added in the fit DLT resectioning, decomposition
Tsai (1987) 3D, or planar with care two linear stages radial, one term Tsai's method
Heikkila and Silven (1997) 3D or planar DLT radial and tangential none
Zhang (2000) planar, ≥3\ge 3 views (2 with zero skew) closed form from homographies radial, in the fit Zhang's method
vanishing points scene with orthogonal directions closed form none vanishing point calibration
self-calibration none, a rigid scene from the Kruppa equations or the absolute quadric in a bundle adjustment self-calibration

All of these end, when accuracy matters, with a Levenberg-Marquardt minimization of EE over all parameters, which is a bundle adjustment with the 3D points held fixed. OpenCV's calibrateCamera and the MATLAB toolbox of Bouguet follow Zhang's start and this refinement.

AlgorithmTimeSpacePropertiesCode
Direct linear transformation for camera resectioningΘ(n) worst · average · bestΘ(n) extradeterministicexactofflineiterative1 language
Tsai's calibration methodO(T n) worst · averageO(n) extradeterministicnot exactofflineiterative1 language
Calibration from vanishing pointsΘ(1) worst · average · bestΘ(1) extradeterministicexactofflineiterative1 language
Zhang's calibration methodO(n N + T n N^3) worst · average · bestO(n N^2) extradeterministicnot exactofflineiterative1 language

Bounds

  • Identifiability with a 3D target (theorem). A finite camera matrix has 11 degrees of freedom and each point gives 2 equations, so at least 6 points are needed (5.5 in the count). If all points lie on one plane, PP is not determined: the DLT matrix has a null space of dimension at least 4. The full list of degenerate sets is in HZ section 22.1.
  • Identifiability with a plane (theorem, Zhang 2000). Each view of a plane gives 2 linear equations on the 6 entries, up to scale, of ω=K−TK−1\omega = K^{-\mathsf T} K^{-1}, the image of the absolute conic. So 3 views in general position fix a general KK, and 2 views fix KK with zero skew. The two equations depend only on the orientation of the plane, so views of parallel planes, for example views that differ by a pure translation, give no new information.
  • Optimality (theorem). Under independent, equal variance Gaussian pixel noise and exact target coordinates, minimizing EE is the maximum likelihood estimate. Linear methods minimize an algebraic error instead, and are not optimal.
  • Accuracy (heuristic). The error of the parameters falls roughly as 1/m1 / \sqrt{m} in the number mm of independent measurements, if the views are varied. Views that tilt the target strongly, and corners near the edges of the image, are what fix the principal point and the distortion; Zhang (2000) reports on synthetic data that tilts far from 0 degrees give better results than views facing the camera (a benchmark result).
  • Input size. Every method reads all 2∑jnj2 \sum_j n_j measurements, so no method is faster than linear in the data.

Reductions

  • 3D target to linear algebra. Calibration without distortion from a 3D target reduces to finding the null vector of a 2n×122n \times 12 matrix (DLT resectioning) and an RQ factorization (decomposition).
  • Planar target to homographies. Each view of a plane at Z=0Z = 0 gives the homography H=λK[r1  r2  t]H = \lambda K [r_1 \; r_2 \; t] by the DLT for homographies. The constraints r1Tr2=0r_1^{\mathsf T} r_2 = 0 and ∥r1∥=∥r2∥\|r_1\| = \|r_2\| are linear in ω\omega, and KK follows from ω\omega by a Cholesky factorization.
  • Known intrinsics to pose. If KK and the distortion are known, the pose of each view is a perspective-n-point problem.
  • Refinement to nonlinear least squares. The final step is a sparse nonlinear least squares problem, solved by Levenberg-Marquardt.
  • Stereo to two calibrations. A stereo rig is two calibrations that share the poses of the target, plus one fixed relative pose; see stereo camera calibration.

Applications

  • Metric 3D reconstruction. Triangulation, stereo depth and structure from motion need KK to turn pixels into rays with true angles.
  • Undistortion and rectification. Removing lens distortion, and making the rows of two stereo images match for stereo rectification.
  • Augmented reality. Drawing virtual objects so that they line up with the real scene needs the true field of view and pose.
  • Robotics and measurement. Visual servoing, the pose of parts on a conveyor, and photogrammetric measurement of sizes.
  • Multi-camera systems. Rigs for motion capture, cars and 3D scanners are calibrated jointly so that all cameras share one frame.

References

  1. Richard Hartley and Andrew Zisserman, Multiple View Geometry in Computer Vision, second edition, Cambridge University Press, 2004, Chapter 6, Camera models; Chapter 7, Computation of the camera matrix P (the linear and gold standard methods, restricted cameras and radial distortion)
  2. Zhengyou Zhang, A flexible new technique for camera calibration, IEEE Transactions on Pattern Analysis and Machine Intelligence 22(11), 2000, 1330-1334, the whole paper (calibration from views of a plane, the closed form start and the maximum likelihood refinement)
  3. Roger Y. Tsai, A versatile camera calibration technique for high-accuracy 3D machine vision metrology using off-the-shelf TV cameras and lenses, IEEE Journal on Robotics and Automation 3(4), 1987, 323-344, the whole paper (the camera model with radial distortion and the two stage method)
  4. Janne Heikkila and Olli Silven, A four-step camera calibration procedure with implicit image correction, Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 1997, 1106-1112, the whole paper (linear start, nonlinear fit with radial and tangential distortion)
  5. Peter Sturm, Srikumar Ramalingam, Jean-Philippe Tardif, Simone Gasparini and Joao Barreto, Camera models and fundamental concepts used in geometric computer vision, Foundations and Trends in Computer Graphics and Vision 6(1-2), 2011, 1-183, the overview of camera models and of calibration approaches
  6. Richard Szeliski, Computer Vision, Algorithms and Applications, second edition, Springer, 2022, Chapter 11, Structure from motion and SLAM (the part on geometric intrinsic calibration)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a contract.yaml