ROBOTICS 101Concept explainer

Lens Distortion and Camera Calibration

Real lenses are not perfect pinholes. Wide-angle lenses bow straight lines outward like a barrel, and some lenses pinch them in like a pincushion. Calibration measures this so the robot can undo it before doing any geometry.

The distortion model

Working in normalized image coordinates \((x, y)\) with \(r^2 = x^2 + y^2\), the widely used Brown-Conrady model moves each point to

$$\begin{aligned} x_d &= x\,(1 + k_1 r^2 + k_2 r^4) + 2p_1 x y + p_2 (r^2 + 2x^2) \\ y_d &= y\,(1 + k_1 r^2 + k_2 r^4) + p_1 (r^2 + 2y^2) + 2p_2 x y \end{aligned}$$

Negative \(k_1\) gives barrel distortion and positive \(k_1\) gives pincushion. The \(p\) terms come from a lens that is slightly tilted relative to the sensor.

What to notice

Press "Calibrate from straight lines". The page searches for the \(k_1\) and \(k_2\) that make the grid lines straight again, using only the bent image. That is the core idea of calibration: we know the checkerboard's lines are straight, so any bending must be the lens. Real calibration, such as OpenCV's, also estimates the focal length and image center from several views of the board.

Distortion is small near the center and large near the edges, so ignoring it hurts most for wide-angle cameras, which robots use a lot.