The Pinhole Camera Model
Point a camera at a chessboard and snap a photo. The parallel edges of the squares appear to converge toward a horizon. Nothing in the physical board changed. Yet straight lines bend toward vanishing points on the image. Explaining this convergence — the essential signature of perspective — requires a precise geometric model. It must describe how light travels from a three-dimensional scene onto a two-dimensional sensor. The pinhole camera model supplies exactly that. It is a minimal, idealized description of image formation through a single point aperture, with no lens and no blur. This model matters because nearly every camera used in computer vision is treated mathematically as a pinhole camera plus corrections. This includes everything from a phone camera to a satellite imager. Camera calibration, Stereo Vision, structure-from-motion, augmented reality overlays, and 3D reconstruction all begin the same way. They start by writing down the pinhole projection equations. Then they estimate the unknown parameters inside them. Without this model there is no principled way to relate a pixel coordinate to a physical ray in space. Therefore there is no way to reason about depth, motion, or 3D structure from 2D images. The big picture is a linear-algebraic one. Perspective projection produces the nonlinear-looking effect of vanishing points. Despite this, it can be written as a single matrix multiplication in homogeneous coordinates. This is the payoff of choosing the right coordinate representation. A 3D point becomes a 4-vector. A 2D image point becomes a 3-vector. The entire imaging process — rotation, translation, and perspective division — collapses into one matrix. This is the camera projection matrix. This article builds the pinhole model from first principles. It covers the geometry of a point aperture, the derivation of the perspective projection equations, and the intrinsic and extrinsic parameterization. It also covers the homogeneous-coordinate matrix formulation. It closes with a fully worked numerical example, a table of common errors, and the history of the model. This history predates photography by centuries.
- A pinhole camera forms an image by letting light pass through a single infinitesimal aperture, producing a sharp, inverted, perspectively correct image with no lens.
- The core relationship is similar triangles: a 3D point at depth projects to image coordinates scaled by focal length and divided by .
- Homogeneous coordinates convert this nonlinear division into a linear matrix multiply, giving the camera matrix .
- (intrinsics) encodes focal length, pixel scale, and principal point; (extrinsics) encodes the camera's pose in the world.
- Depth is fundamentally lost in a single image — pinhole projection is a many-to-one map, which is why triangulation needs two or more views.
- The model is the foundation for Camera Calibration, Stereo Vision, and 3D reconstruction, and is refined later by lens models that add distortion and finite aperture effects.
Perspective projection through a point aperture is division by depth, and choosing homogeneous coordinates turns that division into a single linear matrix multiplication.
The idea
A pinhole camera is an idealized imaging device: light from a scene passes through a single infinitesimally small aperture and lands on a flat image plane, with no lens bending the rays. Because the aperture is a single point, each scene point sends exactly one ray of light through it, so each 3D point maps to exactly one 2D point on the image plane. This gives the cleanest possible geometric model of image formation, building directly on the The Image Formation Model idea that an image is the result of geometric projection combined with radiometric measurement. The key geometric fact is similar triangles. Place the pinhole at the origin of a camera-centered coordinate system, with the optical axis along , and the image plane at distance (the focal length) in front of the aperture (a convenient fiction — physically the image forms behind the pinhole, inverted, but placing a virtual plane in front avoids the inversion and is optically equivalent). A scene point , with being depth along the optical axis, projects to the image point
This is perspective projection: image coordinates scale inversely with depth, which is exactly why distant objects appear smaller and parallel lines appear to converge. The division by is the mathematical seed of every perspective effect — foreshortening, vanishing points, and the impossibility of recovering absolute scale from a single image. To turn pixel measurements into these physical coordinates, the model separates two kinds of parameters. Intrinsic parameters describe the camera itself — focal length in pixels, the pixel aspect ratio, skew, and the principal point (where the optical axis pierces the image plane, ideally the image center). Extrinsic parameters describe where the camera sits in the world — a rotation and translation mapping world coordinates into the camera's coordinate frame. Separating these is what allows a single camera model to be reused across different poses, and it is the parameterization that Camera Calibration procedures solve for.
How it works
The projection pipeline has three logical stages, each a coordinate transformation, and each expressible as multiplication by a matrix once homogeneous coordinates are introduced.
Stage 1 — World to camera (extrinsics). A 3D point given in world coordinates is transformed into the camera's coordinate frame by a rigid transformation:
where is a rotation matrix and is a translation vector. This places the point relative to the camera, with the camera's optical axis as the -axis.
Stage 2 — Camera to normalized image plane (perspective division). The camera-frame point is projected through the pinhole onto a plane at unit distance:
This is the only nonlinear step in the whole pipeline — an actual division — and it is the step that discards depth information.
Stage 3 — Normalized image to pixel coordinates (intrinsics). The normalized coordinates are scaled and shifted into pixel units using the intrinsic matrix
where are the focal length expressed in pixels along each axis (allowing for non-square pixels), is a skew term (nearly always zero for modern sensors), and is the principal point. The trick that makes this pipeline a single matrix is homogeneous coordinates: represent the 3D point as a 4-vector and the resulting 2D pixel as a 3-vector up to scale. Then the entire projection is
where denotes equality up to a nonzero scalar, and is the camera projection matrix. The perspective division that was explicit in Stage 2 is now implicit: it is recovered by dividing the resulting 3-vector by its third coordinate. ```
# PSEUDOCODE — Pinhole projection of a 3D point to a pixel function PROJECT_POINT(P_world, R, t, K):
# P_world: 3-vector (X, Y, Z) in world coordinates
# R: 3x3 rotation matrix, t: 3x1 translation vector (extrinsics)
# K: 3x3 intrinsic matrix
# Stage 1: world -> camera frame P_cam = R * P_world + t # 3-vector (Xc, Yc, Zc) if P_cam.Z <= 0: return NULL # point is behind the camera: no image formed
# Stage 2: camera frame -> normalized image plane (perspective division) x_n = P_cam.X / P_cam.Z y_n = P_cam.Y / P_cam.Z p_n = (x_n, y_n, 1) # homogeneous normalized point
# Stage 3: normalized -> pixel coordinates via intrinsics p_pixel_h = K p_n # 3-vector (uw, v*w, w), here w = 1 u = p_pixel_h[0] / p_pixel_h[2] v = p_pixel_h[1] / p_pixel_h[2] return (u, v)
function PROJECT_MATRIX_FORM(P_world_h, P):
# P_world_h: homogeneous 4-vector (X, Y, Z, 1)
# P: 3x4 camera matrix, P = K [R | t] q = P * P_world_h # 3-vector (qx, qy, qw) if qw <= 0: return NULL # behind camera return (qx / qw, qy / qw) ``` The two functions are equivalent; `PROJECT_MATRIX_FORM` is the form used in practice because building once lets every subsequent point be projected with one matrix-vector product.
The diagram makes explicit why the process is called a pipeline: the world point is first re-expressed in the camera's frame (), then projected through the aperture with a division by depth, then rescaled onto the discrete pixel grid (). Each arrow is one matrix (or one division); composing all three gives the single matrix .
Complexity & correctness
Time complexity. Projecting a single point is : two constant-size matrix-vector products ( times , then a divide). Projecting points, as when rendering a full 3D model or reprojecting a point cloud, is therefore , and this is optimal since every point's coordinates must be touched at least once (an lower bound because the output has points, each requiring examination). In practice the matrix is precomputed once per camera pose, amortizing the cost of forming (itself matrix multiplications) across all points.
Space complexity. additional space per camera (the matrix, 12 numbers, or equivalently 5 intrinsic and 6 extrinsic degrees of freedom), plus for storing the input points and output pixels, which is required simply to hold the data.
Correctness argument. The claim to verify is that the matrix formulation exactly reproduces the geometric similar-triangles projection. Write ; by definition of homogeneous equivalence,
Dividing the first two components by the third (the homogeneous-to-Cartesian step) gives, when ,
which is precisely "scale the similar-triangle projection by focal length and shift by the principal point." This matches the Stage-2/Stage-3 derivation term for term, so the matrix form is not an approximation — it is an algebraic repackaging of the same geometry, valid whenever . The invariant preserved at every stage is: the ray from the world point through the camera center, expressed in the current coordinate frame, always intersects the corresponding plane at the correctly scaled position — rotation and translation preserve this ray, and the final division reads off where it crosses the image plane.
Honesty about the model's limits. Pinhole projection is fundamentally a many-to-one map: every point along the ray from the camera center through projects to the same pixel, so depth cannot be recovered from a single image — this is why monocular depth is ill-posed without additional priors, and why Stereo Vision uses two views to triangulate. The model also assumes an infinitesimal aperture (zero light, infinite depth of field, no blur), which is physically unrealizable; real cameras use a lens with finite aperture, introducing defocus blur and geometric distortion, refined in the study of Lenses and Optics. Finally, the model assumes a perfect, noise-free, continuous image plane, whereas real sensors discretize the plane into finite pixels, the subject of Digital Images and Sampling.
Worked example
Consider a camera with intrinsics px, principal point (a image), zero skew, positioned at world coordinates meters looking straight down the world -axis with no rotation relative to world axes (). We want to project the world point meters — half a meter right, quarter meter up, five meters ahead of the world origin. The extrinsic transform used here is , with chosen as the camera position expressed as a translation applied after rotation (i.e., where is camera center in world coordinates; here and , so ).
| Step | Computation | Result |
|---|---|---|
| Camera center | given | |
| Translation | ||
| Camera-frame point | ||
| Depth check | in front of camera ✓ | |
| Normalized projection | ||
| Apply | ||
| Add principal point |
So lands at pixel — slightly right of and below the image center , matching intuition since the point is to the right of and above the world origin but the camera looks straight ahead (the vertical sign convention here takes image increasing downward, so "up in the world" shows as a smaller offset consistent with the chosen axis convention; the sign details depend on convention but the magnitude and mechanism are what matter). Now verify the many-to-one claim: the world point lies on the same ray from the camera center through (it is the camera-frame vector , scaled by ). Projecting it:
identical normalized coordinates, hence identical pixel despite being twice as far away. This confirms the invariant from the correctness section directly: points differing only by a positive scalar multiple along a camera-frame ray project to the same pixel, which is exactly the depth-ambiguity the pinhole model predicts. As a second check, project the camera center itself's forward axis point in camera frame (i.e., a point straight down the optical axis): , , giving pixel — exactly the principal point, as required, since points on the optical axis must map to where that axis pierces the image plane.
Common pitfalls & traps
| Pitfall | Why it happens | Fix |
|---|---|---|
| Forgetting the cheirality check () | Naively applying the formula to points behind the camera yields a mirror-flipped, spurious projection instead of "no image" | Always test before dividing; discard or flag points that fail |
| Confusing camera center with translation | in general; | Be explicit about which convention ( vs. ) is used, and stay consistent |
| Assuming square pixels () | Older or asymmetric sensors have non-square photosites | Calibrate separately; never hardcode equality |
| Ignoring skew or principal point offset | Assuming without calibration | Estimate via Camera Calibration rather than guessing |
| Treating pinhole projection as invertible | A single 2D point corresponds to an entire 3D ray, not a unique point | Use multiple views (Stereo Vision) or additional priors to recover depth |
| Dividing before checking for | Points exactly on the camera plane cause division by zero | Guard the division; treat as undefined/degenerate |
Pioneers & history
The geometry behind the pinhole camera long predates cameras themselves: the convergence of light rays through a small aperture was documented by natural philosophers studying optics and later formalized by Renaissance artists developing linear perspective, before being rigorously connected to the mathematics of projective geometry.
Origins · 1 minIbn al-Haytham (Alhazen) and how this was discovered
Alhazen's Book of Optics gave the first systematic account of how light traveling in straight lines through a small aperture forms an inverted image — the physical principle underlying the pinhole camera, studied centuries before photographic capture existed.
- Lens distortion introduced by the glass elements - Sensor noise accumulating over the image width - Perspective division by depth , which shrinks farther points' projected coordinates ✓ - Incorrect placement of the principal point
:::quiz[Given camera matrix and a world point in homogeneous coordinates, how is the final pixel obtained?]
- Multiply by the point and take the result directly as
- Multiply by the point, then divide the first two components by the third ✓
- Add to before multiplying by the point
- Take the eigenvector of corresponding to the point
Ask the tutor: How does adding a second camera (stereo) resolve the depth ambiguity inherent in a single pinhole projection?
Why is it called a "pinhole" camera if real cameras use lenses?
The name refers to an idealized model, not a literal design choice in modern cameras. A true pinhole (a single point-sized aperture) would form a perfectly sharp image at any distance because light from each scene point travels along exactly one ray to the sensor, with no lens to focus or blur it. Real cameras use lenses to gather more light and control focus, but the underlying projective geometry — how a 3D point maps to a 2D image position — is, to first order, identical to the pinhole case. This is why the pinhole model is used as the baseline geometric description, with lens effects such as distortion and depth-of-field layered on top in the study of Lenses and Optics.
What exactly is lost when a 3D scene is projected onto a 2D pinhole image?
Depth along the viewing ray is lost. Every point on the ray from the camera center through a given 3D point projects to the same pixel, regardless of how far along that ray the point sits, because the projection formula divides both and by the same . This makes the pinhole map many-to-one: infinitely many 3D points collapse onto one pixel. Recovering depth requires additional information — a second view (triangulation in Stereo Vision), known object size, motion over time, or learned monocular priors — none of which are contained in the geometry of a single pinhole image alone.
What is the difference between intrinsic and extrinsic parameters?
Intrinsic parameters describe properties internal to the camera: focal length in pixels (), skew, and the principal point, all bundled into the matrix . They do not change if the camera is moved, only if its internal optics or sensor change. Extrinsic parameters describe the camera's pose in the world: a rotation and translation that convert world coordinates into the camera's coordinate frame. Separating the two lets a single calibrated be reused across arbitrarily many camera positions, which is exactly what Camera Calibration procedures exploit by holding fixed while estimating a different per photograph.
Why use homogeneous coordinates instead of ordinary Cartesian coordinates?
Perspective projection involves a division by depth, which is a nonlinear operation and cannot be written as a matrix multiplication in ordinary Cartesian coordinates. Homogeneous coordinates add an extra dimension and treat vectors as equivalent up to nonzero scaling, which lets the division be deferred: the linear part (rotation, translation, intrinsic scaling) is done first via one matrix multiplication, and the division by the last coordinate is applied only at the very end to recover Cartesian pixel coordinates. This turns the entire imaging pipeline into a single matrix, dramatically simplifying calibration, composition of transformations, and downstream algorithms such as triangulation and bundle adjustment.
Can the pinhole model handle a camera pointed at an angle or upside down?
Yes — that is precisely the role of the extrinsic parameters and . Rotation reorients the world so that, in the camera's own frame, the optical axis is always the -axis; translation repositions the origin to the camera center. Once a world point is expressed in this camera-centered frame, the same projection formula (, etc.) applies regardless of how the camera was physically tilted, panned, or inverted in the world. This is why the extrinsic-intrinsic split is so powerful: all camera orientations reduce to the identical canonical projection after the rigid transform.
Does the pinhole model apply to cameras with very wide fields of view, like fisheye lenses?
Only approximately, and often poorly. The linear pinhole model assumes straight lines in the world map to straight lines in the image, which holds for rectilinear lenses over moderate fields of view but breaks down for fisheye or very wide-angle optics, where significant radial distortion curves straight lines. In practice, real lenses are modeled as an ideal pinhole projection followed by a distortion correction step, studied separately under Lenses and Optics, and calibration routines estimate both the pinhole intrinsics and the distortion coefficients simultaneously so that fisheye imagery can still be rectified into an approximately pinhole-consistent image.
Is the pinhole projection matrix unique for a given camera and pose?
Only up to a global scale factor. Because is an equivalence up to nonzero scaling, multiplying every entry of by the same nonzero constant produces an identical set of projected pixels. This is why is typically normalized (for instance, by fixing its last row's norm) before comparing camera matrices numerically, and why calibration algorithms recover , or equivalently , , , only up to this inherent scale ambiguity, which is harmless for projection but must be handled carefully when decomposing back into , , and via matrix factorization.