TL;DR
A pinhole camera forms an image by letting light from each scene point pass through one small opening, so every point lands on a flat sensor at a position set by where it sits relative to that opening. The model says the image position is the point's sideways offset divided by its depth, times a focal length. In homogeneous coordinates that division becomes one matrix product followed by a single divide.
Where you'll see it: camera calibration, structure from motion, two-view geometry, and the projection step in every 3D renderer.
Intuition
Put a sheet of paper a short distance behind a pinhole in a dark box, facing a sunlit window. An upside-down picture of the window appears on the paper. Each point of the window sends light in a straight line through the hole, and that light lands on one spot. Light from the top of the window ends up at the bottom of the paper, which is why the image is inverted.
This is the camera obscura, used for centuries before photographic film. The pinhole model is the same picture drawn with geometry. Put the hole, which is the centre of projection, at the origin. The sensor sits a distance (the focal length) behind it. A point at sideways offset and depth lands at a height on the sensor that scales like . The farther a point is, the smaller its image. That single fact is the whole perspective effect, and it is why parallel railway tracks appear to meet at a vanishing point.
Why build this model at all? It turns a 3D question ("where does this object appear?") into a 2D one, and it lets a program run the process backwards: given where things appear in images, estimate where they are in the scene.
- X = 1, f = 2
- X = 2, f = 2
flowchart LR W["3D point (X, Y, Z)"] --> R["Straight ray through the centre of projection"] R --> I["Image point (fX/Z, fY/Z)"]
The math
Setup
Place the camera's centre of projection at the origin, with the optical axis along the -axis. The image plane is the plane , where is the focal length. (Real sensors sit behind the centre. Placing the image plane in front avoids an upside-down image in the formulas and is the usual convention.) A world point written in camera coordinates is , and means the point is in front of the camera.
A camera with focal length maps a point with to the image point
Where does the formula come from? The ray from the origin to the point is the set of points for . It meets the image plane when its -coordinate equals , so , which gives . Substituting gives the point on the plane. Its first two coordinates are the image point.
Projection as one matrix
Matrix multiplication is linear, and a linear map cannot divide one coordinate by another. So no ordinary matrix maps straight to . The fix is to use homogeneous coordinates: write the 3D point as , and write the image point as a triple that stands for .
Dividing by recovers and . The matrix is because the input is a 3D point and the output is a 2D image point.
Pixels: the intrinsic matrix
A real sensor counts in pixels, and its optical axis may not hit the exact middle. Collect these details in the intrinsic matrix
Here and are the focal lengths measured in pixels, is the principal point (where the optical axis meets the sensor), and is the skew, which is zero on almost every modern camera. With , multiplying by and dividing by the third entry gives and .
Placing the camera in the world
The point usually starts in world coordinates. A rotation matrix and a translation vector move it into camera coordinates: . The full model is
where means equal up to a nonzero scale factor. The matrix has 11 degrees of freedom: 5 from , 3 from the rotation and 3 from the translation. The twelfth entry is absorbed by the scale.
Worked examples
Use a focal length in normalised units, and a point with and .
- At depth : and .
- Move the point to depth : and .
Interpretation: doubling the depth halves both image coordinates. The image shrinks in inverse proportion to depth.
Take a camera with pixels, zero skew and principal point . Its pose is a rotation with translation . The world point is .
- Move to camera coordinates: , so .
- Apply to : the first entry is , the second is , and the third is .
- Divide by the third entry: .
Interpretation: the point lands in the middle column and 400 pixels down, in the lower half of the 480-row image. The rotation and translation did the placing, and turned the result into pixel units.
Tradeoffs and failure modes
The pinhole model is an idealisation, but it is the first-order model for almost every camera. The table lists where it breaks and what to do.
| Situation | What goes wrong | Better choice |
|---|---|---|
| Wide-angle or cheap lens | Straight lines bend near the image edge (radial distortion) | Add distortion coefficients and calibrate them |
| Scene depth varies little compared with its distance | Depth changes barely move the image, so perspective adds little | Weak-perspective or orthographic camera |
| Point with (behind the camera) | The division flips sign or blows up, so the formula is meaningless | Discard or clip such points before projecting |
| Real lens with a finite aperture | Depth-dependent blur; a pinhole gives sharp everything | Thin-lens model, or accept the error |
| Rolling shutter or fast motion during exposure | Each image row sees a slightly different camera pose | Model a pose that changes with time |
A real pinhole lets in too little light, which is why real cameras use lenses. A lens is still well described by the pinhole model once distortion and focus are accounted for.
History
A Chinese text from the Mohist school, from the 5th to 4th century BCE, describes an inverted image formed through a small hole. Ibn al-Haytham's Book of Optics (early 11th century) explained that light travels in straight lines and used a pinhole to study the image of the sun. The camera obscura spread through Europe in the 16th century as a drawing aid. Leon Battista Alberti's De pictura (1435) gave the rules of linear perspective, which describe a scene by its projection onto a plane. That is the same geometry as the pinhole.
The homogeneous coordinates that make the projection a matrix come from 19th-century projective geometry. The matrix form of the camera model is standard in computer vision. Hartley and Zisserman's Multiple View Geometry in Computer Vision (2000) is the reference most people learn it from.
Check yourself
QuestionRecall: what property of light does the pinhole model rely on?Show answer
QuestionComputation: a camera with focal length sees a point at . Where does it land on the image?Show answer
QuestionWhy: why can no ordinary matrix perform the pinhole projection directly, and how do homogeneous coordinates fix this?Show answer
QuestionApplied: a 640 by 480 camera has pixels, zero skew and principal point . A point is at camera coordinates . Where does it land?Show answer
Sources
- Pinhole camera model (Wikipedia)
- Camera matrix (Wikipedia)
- Camera obscura (Wikipedia)
- Hartley and Zisserman, Multiple View Geometry in Computer Vision (Cambridge University Press, 2000)