Reprojection Error

The reprojection error is the fundamental geometric residual of visual SLAM: it measures how well a hypothesized 3D point and camera pose explain an actual 2D feature observation. Take a 3D point Xj\mathbf{X}_j (world frame), a camera pose TiSE(3)T_i \in SE(3) (world-to-camera), and the observed pixel location zij\mathbf{z}_{ij} of that point in image ii:

eij=zijπ ⁣(TiXj)\mathbf{e}_{ij} = \mathbf{z}_{ij} - \pi\!\left(T_i \mathbf{X}_j\right)

where π:R3R2\pi : \mathbb{R}^3 \to \mathbb{R}^2 is the camera projection function. For a pinhole camera with intrinsics (fx,fy,cx,cy)(f_x, f_y, c_x, c_y) and camera-frame point Xc=(X,Y,Z)T=TiXj\mathbf{X}^c = (X, Y, Z)^T = T_i \mathbf{X}_j:

π(Xc)=[fxX/Z+cxfyY/Z+cy]\pi(\mathbf{X}^c) = \begin{bmatrix} f_x \, X / Z + c_x \\ f_y \, Y / Z + c_y \end{bmatrix}

The error lives in pixels — directly comparable to the feature detector’s localization noise (typically around a pixel), which makes it easy to set thresholds and covariances.

From residual to cost function

Under the assumption of Gaussian observation noise zijN(π(TiXj),Σij)\mathbf{z}_{ij} \sim \mathcal{N}\left(\pi(T_i\mathbf{X}_j), \Sigma_{ij}\right), maximum-likelihood estimation of poses and points is exactly the weighted nonlinear least-squares problem

C=(i,j)OeijTΩijeijC = \sum_{(i,j) \in \mathcal{O}} \mathbf{e}_{ij}^T \, \Omega_{ij} \, \mathbf{e}_{ij}

where Ωij=Σij1\Omega_{ij} = \Sigma_{ij}^{-1} is the information matrix and O\mathcal{O} is the set of (pose, point) observation pairs. Each summand is a squared Mahalanobis distance; in practice Σij\Sigma_{ij} is often isotropic and scaled with the image-pyramid level at which the feature was detected (coarser level = noisier = lower weight).

Because false matches produce huge residuals that would dominate a quadratic cost, real systems wrap each term in a robust kernel ρ\rho (Huber, Cauchy), giving ρ(eijTΩijeij)\sum \rho\left(\mathbf{e}_{ij}^T \Omega_{ij} \mathbf{e}_{ij}\right), and prune observations whose chi-square value exceeds a threshold.

Optimization

The cost is nonlinear in the pose (through the SE(3)SE(3) action and the perspective division). Linearizing e(x+Δx)e(x)+JΔx\mathbf{e}(\mathbf{x} + \Delta\mathbf{x}) \approx \mathbf{e}(\mathbf{x}) + J \Delta\mathbf{x} around the current estimate and solving the Gauss–Newton normal equations (JTΩJ)Δx=JTΩe\left(J^T \Omega J\right)\Delta\mathbf{x} = -J^T \Omega\, \mathbf{e} iteratively is the standard approach. By the chain rule the Jacobian factors into

e()=πXcXc()\frac{\partial \mathbf{e}}{\partial (\cdot)} = -\frac{\partial \pi}{\partial \mathbf{X}^c} \cdot \frac{\partial \mathbf{X}^c}{\partial (\cdot)}

with π/Xc\partial \pi / \partial \mathbf{X}^c a 2×32 \times 3 matrix containing the 1/Z1/Z and X/Z2-X/Z^2, Y/Z2-Y/Z^2 terms, and the second factor differing depending on whether we differentiate w.r.t. the pose (via a Lie-algebra perturbation, 2×62 \times 6) or the point (2×32 \times 3).

Which problems minimize it

Alternatives for comparison: photometric error (direct methods compare pixel intensities instead of feature positions) and 3D point-to-point/point-to-plane error (ICP). Reprojection error is preferred when reliable feature correspondences exist because its pixel-space noise model matches how the measurements were actually made.

Why it matters for SLAM