Algorithm Search⌘K

Problemcore

Stereo camera calibration

Also called stereo rig calibration.

Estimate the intrinsics of two cameras and the rigid motion between them from shared views of a pattern, as needed for rectification and metric depth.

Stereo camera calibration finds the intrinsics and distortion of two cameras on a rigid rig, and the fixed rotation RR and translation tt that take points from the frame of the first camera to the frame of the second. The input is pairs of images of a calibration pattern, taken by both cameras at the same moment. The result is what stereo rectification needs to align the image rows, and what depth from disparity needs to turn a disparity into a metric depth: the baseline ∥t∥\|t\| gives the scale. It differs from single camera calibration by the shared relative pose, which ties the two cameras together, and from the relative pose problem by the known pattern, which fixes the scale of tt.

In plain words

Two cameras are bolted side by side, like two eyes. To measure depth, you need to know each camera's own numbers, and exactly where the second camera sits relative to the first, including the distance between them. You hold a checkerboard in front of both cameras and take photos with both at once, several times, in different positions. Each photo pair tells you where the board was for each camera. Since the cameras do not move relative to each other, the step from one camera to the other must be the same in every pair. You find that one step, then adjust all the numbers together so that the board corners land where they show in all the photos.

Definition

Use the conventions of the extrinsic parameters page: a point XX in the frame of the pattern has camera coordinates Xc=RjX+tjX_{c} = R_j X + t_j in view jj. For a rigid rig, the poses of the two cameras in view jj satisfy

R2j=R R1j,t2j=R t1j+t,R_{2j} = R\, R_{1j}, \qquad t_{2j} = R\, t_{1j} + t,

where (R,t)(R, t) is the fixed pose of camera 2 relative to camera 1: Xc2=RXc1+tX_{c2} = R X_{c1} + t. If the two poses of one view are known, then

R=R2jR1jT,t=t2j−R t1j.R = R_{2j} R_{1j}^{\mathsf T}, \qquad t = t_{2j} - R\, t_{1j}.

The center of camera 2 in the frame of camera 1 is −RTt-R^{\mathsf T} t, and the baseline is ∥t∥\|t\|.

Input. NN pairs of images of a pattern with known model points mim_i; in view jj, the pixels uij(1)u^{(1)}_{ij} in camera 1 and uij(2)u^{(2)}_{ij} in camera 2.

Output. K1K_1, K2K_2, the distortion of each camera, (R,t)(R, t), and the pose (R1j,t1j)(R_{1j}, t_{1j}) of the pattern in camera 1 for each view.

Criterion. The maximum likelihood estimate under Gaussian pixel noise minimizes

∑j∑i(∥uij(1)−π1(R1j,t1j;mi)∥2+∥uij(2)−π2(RR1j,Rt1j+t;mi)∥2),\sum_{j} \sum_{i} \Big( \big\| u^{(1)}_{ij} - \pi_1(R_{1j}, t_{1j}; m_i) \big\|^2 + \big\| u^{(2)}_{ij} - \pi_2(R R_{1j}, R t_{1j} + t; m_i) \big\|^2 \Big),

where πc\pi_c is the projection of camera cc with its intrinsics and distortion. The poses of camera 2 are not free: they are fixed by the poses of camera 1 and (R,t)(R, t), which is what makes this more than two separate calibrations.

Variants

  • Fixed intrinsics. Each camera is calibrated alone first, for example with Zhang's method, and the stereo step fits only (R,t)(R, t) and the pattern poses. This is common when each camera can see the pattern alone more easily.
  • Joint fit. All intrinsics, distortions, (R,t)(R, t) and the poses are fitted together, which uses the stereo views to improve the intrinsics too.
  • Without a pattern. With known intrinsics and matched points of any scene, the relative pose comes from the essential matrix, but only up to the scale of tt. A known length in the scene, or a known baseline, then fixes the scale.
  • Multi-camera rigs. Three or more cameras with fixed relative poses. Pairwise poses are combined in a graph, for example by rotation averaging, and refined jointly.
  • Different sensors. A color camera with an infrared or depth camera; the model is the same, but the pattern must be visible to both.
  • Online recalibration. Small corrections to (R,t)(R, t) during use, from the epipolar geometry of natural image matches, to follow changes in the rig due to heat or shock.

Examples

Two cameras side by side. In one view, camera 1 sees the pattern with R11=IR_{11} = I and t11=(0,0,5)t_{11} = (0, 0, 5), and camera 2 with R21=IR_{21} = I and t21=(−0.1,0,5)t_{21} = (-0.1, 0, 5). Then

R=I IT=I,t=(−0.1,0,5)−(0,0,5)=(−0.1,0,0).R = I \, I^{\mathsf T} = I, \qquad t = (-0.1, 0, 5) - (0, 0, 5) = (-0.1, 0, 0).

Camera 2 is 0.10.1 units to the right of camera 1 (−RTt=(0.1,0,0)-R^{\mathsf T} t = (0.1, 0, 0)), and the baseline is b=0.1b = 0.1. The essential matrix E=[t]×RE = [t]_\times R has the rows (0,0,0)(0, 0, 0), (0,0,0.1)(0, 0, 0.1) and (0,−0.1,0)(0, -0.1, 0). For normalized image points (x1,y1,1)(x_1, y_1, 1) and (x2,y2,1)(x_2, y_2, 1), the epipolar constraint x2TEx1=0.1(y2−y1)=0x_2^{\mathsf T} E x_1 = 0.1 (y_2 - y_1) = 0 says that matching points lie on the same row: this rig is already rectified.

Depth. With the same rig, f=500f = 500 pixels for both cameras and a disparity of d=20d = 20 pixels, the depth is Z=fb/d=500⋅0.1/20=2.5Z = f b / d = 500 \cdot 0.1 / 20 = 2.5 units. A 1% error in the calibrated baseline gives a 1% error in every depth.

A count. With 15 views of a board with 54 corners seen by both cameras, there are 2⋅2⋅54⋅15=32402 \cdot 2 \cdot 54 \cdot 15 = 3240 equations. With zero skew and 2 radial distortion terms per camera, the unknowns are 2⋅(4+2)=122 \cdot (4 + 2) = 12 intrinsic terms, 6 for (R,t)(R, t) and 6⋅15=906 \cdot 15 = 90 for the poses, so 108 in total.

Known algorithms

  • Calibrate each camera, compose, refine. Calibrate each camera with Zhang's method, compute (R,t)(R, t) from each view by the formulas above, take a robust mean over the views (the median of tt and a rotation average of RR), and then minimize the criterion with Levenberg-Marquardt. This is the scheme of the stereo functions of OpenCV and of the MATLAB toolbox of Bouguet.
  • Joint bundle adjustment. For many cameras, a bundle adjustment with the pattern points held fixed and the rig poses shared over all views.
  • Essential matrix and a scale. Without a pattern: estimate the essential matrix from matched points with known intrinsics, decompose it into RR and the direction of tt, and fix the length of tt from one known distance.

Bounds

  • Scale (theorem). From image matches alone, with known intrinsics, tt is determined only up to a positive scale: scaling the scene and tt by the same factor leaves all images the same (HZ section 9.6). A pattern of known size removes this ambiguity.
  • One view is enough in principle (theorem). If both cameras are calibrated and both see the pattern in one view, the two poses of that view, and so (R,t)(R, t), are determined. More views only reduce the effect of noise.
  • Depth sensitivity (theorem, to first order). From Z=fb/dZ = f b / d, an error δd\delta d in disparity gives δZ≈Z2δd/(fb)\delta Z \approx Z^2 \delta d / (f b), and a relative error in bb or ff gives the same relative error in ZZ. So calibration errors matter most for far points and short baselines.
  • Vertical alignment (heuristic). After rectification, a vertical error of more than a fraction of a pixel between matching points makes many stereo matching methods, which search along one row, lose matches. The mean vertical error of rectified pattern corners is a practical check of the calibration.

Reductions

  • To single camera calibration. With fixed intrinsics, stereo calibration is two camera calibrations plus the composition R=R2jR1jTR = R_{2j} R_{1j}^{\mathsf T}, t=t2j−Rt1jt = t_{2j} - R t_{1j}, then a small nonlinear fit.
  • To bundle adjustment. The joint fit is a bundle adjustment with known 3D points (the pattern) and a shared rig pose.
  • To the relative pose problem. Without a pattern, it is the relative pose problem for calibrated cameras, plus a scale.
  • Rectification uses it. Stereo rectification takes K1K_1, K2K_2, the distortions, RR and tt as input, and gives the two rotations that make the epipolar lines horizontal.

Applications

  • Depth cameras and 3D scanning. Passive and active stereo sensors need (R,t)(R, t) to compute metric depth by triangulation.
  • Robots and cars. Stereo heads for obstacle detection and mapping, where the baseline sets the range of useful depth.
  • Headsets. VR and AR headsets with several tracking cameras.
  • Motion capture and photogrammetry. Multi-camera rigs calibrated with a wand or a board, 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, Section 9.6, The essential matrix (the relative pose of two calibrated cameras and its scale ambiguity); Section 11.12, Image rectification
  2. Zhengyou Zhang, A flexible new technique for camera calibration, IEEE Transactions on Pattern Analysis and Machine Intelligence 22(11), 2000, 1330-1334, the calibration of each camera from views of a plane, which gives the poses that the stereo calibration combines
  3. Richard Szeliski, Computer Vision, Algorithms and Applications, second edition, Springer, 2022, Chapter 12, Depth estimation (rectification and the relation of disparity to depth)

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 known algorithm
  • a contract.yaml