Camera Calibration and Parameters
Calibration learns how one camera turns 3D world points into 2D pixels: where it sits, how it aims, and how its lens bends the light.
Why Does This Exist?
A camera crushes a 3D world into a flat 2D grid of pixels, losing depth and warping geometry through its lens. Measuring anything from pixels, the real size of an object, the distance to a pedestrian, or where an augmented render should sit, needs the mapping back. Calibration learns that mapping: the camera's internal characteristics plus its position in the world, so every 3D point predicts its pixel.
The one idea you need first. The pinhole camera model says a 3D point is scaled by focal length over depth onto the sensor. Calibration is the procedure that fills in that model's numbers for one real camera. If focal length and projection are unfamiliar, read that page first.
This page is the map of all three parameter groups and how they compose. The warp details live in lens distortion and the checkerboard procedure lives in camera calibration.
Think of It Like This
The artist at the window
You paint a landscape through a glass window. Where you put your chair and which way you face decides what appears where: move left and the mountain slides right. That chair placement is the extrinsics. The window itself is the intrinsics: how far your eye sits from the glass is the focal length, a fishbowl curve in the glass is lens distortion, and the exact center of the pane is the principal point.
To predict where one mountain peak lands on the glass, you need both the chair and the window. The analogy stops at estimation: painters pick a chair, while calibration solves for all of these numbers at once from photos of a known pattern.
How It Actually Works
Projection runs in two steps. First, extrinsics move the point from world coordinates into the camera's frame, where the lens sits at the origin and looks down its -axis. Second, intrinsics scale it onto pixels, with a lens warp applied for real glass.
Extrinsics: world to camera
Extrinsics are a rotation matrix , which captures how the camera is tilted, panned, or rolled, and a translation vector , which captures its , , offset from the world origin. A world point becomes in the camera frame. These six degrees of freedom change every time the camera moves.
Intrinsics: camera to pixels
Intrinsics live in the camera matrix , holding focal lengths and and principal point where the optical axis meets the sensor. They are fixed for one lens: moving the camera never changes them. The pixel follows and , where is depth. Both steps compose into one projection matrix , with in homogeneous form.
Lens distortion
Real lenses curve light, so straight world lines bow outward in wide-angle barrel distortion or inward in pincushion distortion, plus a tangential skew when lens and sensor are not parallel. Coefficients , , , parameterize this warp and are estimated alongside . Undistort first, then apply the pinhole math.
Worked example
Take , , and a camera-frame point . Then and . The point lands on pixel : right of center because is positive, and below center because points down the image.
Code
The point of this snippet is the composition: extrinsics place the point, intrinsics scale it, and the numbers match the hand computation.
import numpy as np
K: np.ndarray = np.array([[800.0, 0.0, 320.0], [0.0, 800.0, 240.0], [0.0, 0.0, 1.0]])R: np.ndarray = np.eye(3)t: np.ndarray = np.zeros(3)
def project(world: np.ndarray) -> tuple[int, int]: """Project a 3D world point to integer pixels with P = K[R|t].""" camera: np.ndarray = R @ world + t u: float = K[0, 0] * camera[0] / camera[2] + K[0, 2] v: float = K[1, 1] * camera[1] / camera[2] + K[1, 2] return (round(u), round(v))
print(project(np.array([1.0, 2.0, 4.0]))) # -> (520, 640)print(project(np.array([0.0, 0.0, 4.0]))) # -> (320, 240)The optical-axis point lands exactly on the principal point , confirming the matrix is assembled correctly.
Watch Out For
Assuming constant intrinsics with autofocus on
Intrinsics are static only while the physical optics stay fixed. Autofocus or a variable zoom shifts the focal length continuously, silently voiding the calibrated . The symptom is reprojection error that grows the longer the session runs. Disable autofocus and auto-zoom for any calibrated task.
Calibrating from one flat pose
Twenty checkerboard shots held dead center and untilted leave the solver blind to distortion at the frame edges and to focal length. The symptom is low training error with terrible corner accuracy in real scenes. Tilt the board, move it into the corners, and vary its distance across shots.
The Quick Version
- Camera calibration learns the mapping from 3D world points to 2D pixels for one camera.
- Extrinsics and say where the camera sits and how it aims, and change with every move.
- Intrinsics hold focal length and principal point, and stay fixed for one lens.
- Distortion coefficients correct the bending of real glass before the pinhole math applies.
- All three compose into one projection matrix .
- Autofocus voids the calibration, and flat single-pose board sets leave distortion unsolved.