Camera Calibration with a Checkerboard
Calibration shows the camera a checkerboard of known size from many angles and solves for the numbers that explain every corner. The verdict is one score: mean reprojection error in pixels.
Why Does This Exist?
Factory specs never describe your exact camera: the lens seated a fraction of a millimetre off, the sensor a touch rotated, the focus ring somewhere unknown. Intrinsic parameters, extrinsic parameters, and lens distortion say what the numbers mean; calibration is how you get them for the camera in your hand. Without it, stereo vision cannot rectify and structure from motion starts from fiction.
Think of It Like This
An eye exam with a known chart
The optometrist shows you a chart of known letters and flips lenses until you read the bottom row. The chart is the checkerboard: every square size known in advance. Each lens flip is a guess at your parameters. Your reading errors are reprojection errors, and the final prescription is the parameter set with the smallest total misread.
The analogy stops at reuse: glasses are fitted per person and stay valid, while calibration dies the moment focus, zoom, or the lens mount changes.
How It Actually Works
Print a checkerboard with known square size, photograph it from to varied poses, and detect its inner corners in each shot. Because the board is flat ( in its own frame) each view gives a homography from board to image, and stacking those homographies yields a closed-form first guess at (Zhang's method). A nonlinear refinement then adjusts , every view's and , and the distortion coefficients together to minimize the reprojection error: for corner , with observed pixel and projected pixel , minimize the mean of over all corners and views.
Worked numbers
One corner is observed at while the current parameters project it to . Its error is:
With four corners scoring , , , and pixels, the mean reprojection error is pixels. Below about one pixel on a clean board, the calibration is solid; several pixels mean something below went wrong.
Code
import math
def reproj_error(obs: tuple[float, float], proj: tuple[float, float]) -> float: return math.dist(obs, proj) # Euclidean gap in pixels
print(round(reproj_error((521.3, 639.1), (520.0, 640.0)), 2)) # -> 1.58print(round(sum([1.58, 0.90, 1.10, 0.70]) / 4, 2)) # -> 1.07Watch Out For
Calibrating with near-parallel board poses
If every shot holds the board flat facing the camera, the views differ only by translation and the focal length stays weakly constrained: many pairs explain the same corners. The optimizer converges, the error looks fine, and fresh angles then misproject badly. Tilt the board steeply in several shots so perspective, not just position, varies.
A misprinted square size
The whole reconstruction inherits the board's stated square size as its unit of length. A printer that scales the page to percent makes every downstream measurement percent short, with zero warning from the reprojection error, which is scale-free. Measure the printed squares with calipers and enter the true size before solving.
The Quick Version
- Calibration photographs a known board from varied poses and solves , per-view and , and distortion jointly.
- Zhang's method gives the closed-form starting guess from stacked homographies.
- The refinement minimizes mean reprojection error, measured in pixels.
- Near one pixel of mean error means success; several pixels mean a setup problem.
- Steeply tilted board poses constrain the focal length; flat frontal ones do not.
- The entered square size becomes the unit of every later measurement.