- Explain why the pinhole camera is used to approximate a real camera.
- Derive pixel coordinates from 3D camera coordinates using similar triangles.
- Describe the roles of the intrinsic and extrinsic camera matrices.
- Use homogeneous coordinates to combine rotation and translation.
- Explain how the full camera matrix maps a homogeneous world point to an image point.
Begin with the pinhole approximation
A real camera is difficult to analyze because it has a wide aperture and several lenses. The pinhole camera replaces that system with an ideal aperture of infinitesimal size—a single point. Light can then reach each sensor location from only one direction.
With a larger opening, multiple light directions would arrive at one sensor point and blur the image. Lenses reduce that blur, but they can produce radial and tangential distortion, neither of which belongs to the pinhole model. Radial distortion may be corrected afterward, while tangential distortion is often negligible with a good camera and lens. The resulting approximation is simple and reasonably accurate.
Set the camera coordinate convention
A world frame often places the x- and y-axes in the ground plane and points the z-axis upward. For a camera frame, the sensor is conventionally parallel to the x- and y-axes, and the camera views along positive z. This z-axis is also known as the optical axis or principal axis. Some conventions, including ones used in computer graphics, view along negative z; the ideas remain applicable, but several signs change.
For now, work only in the camera frame. Put the aperture at its origin and place the image plane behind it, parallel to the x- and y-axes. The optical axis intersects the image plane at its center. Use uppercase W and H for sensor dimensions measured in millimeters, and lowercase w and h for dimensions measured in pixels.
Obtain the projection with similar triangles
View the arrangement from above so that the x- and z-axes are visible; the y-direction follows in the same way. The image-plane distance from the aperture is the focal length F in millimeters. The extreme captured rays define the angle of view. Consider a scene point whose camera coordinates in this view are (X, Z).
The ray from that point passes through the aperture before meeting the sensor. Because the sensor lies on the opposite side, its x-coordinate is negative. Write this coordinate as -U, which makes U positive when X is positive in this arrangement. Similar triangles then give the projection ratio.
Canceling the two negative signs produces the basic pinhole relation.
Convert the projection to pixel units
Doubling only the focal length changes the angle of view and therefore the image. Doubling the image plane at the same time restores the original angle of view and the same continuous image. Thus, infinitely many pinhole cameras can form an identical image: the relative scale matters, rather than the two absolute sizes.
Choose the common factor to express lengths in pixels. If w is sensor width in pixels and W is its width in millimeters, then k=w/W is the pixel count per millimeter. Scaling U gives a pixel location, and scaling F gives the focal length in pixels.
This expression assumed that the sensor was centered on the optical axis. If it is displaced, the optical axis meets the sensor at the principal point rather than at the image center. Let that pixel offset be (u₀, v₀). Adding the offset back gives the corrected coordinates.
Assemble the intrinsic matrix
Multiplying the pixel equations by Z makes them suitable for matrix notation.
After division by Z, the left vector represents [u, v, 1]ᵀ. The symbol ∼ states that two homogeneous vectors differ only by a nonzero scale; here that scale is 1/Z. The 3 × 3 matrix is the intrinsic camera matrix K. Some presentations include image-plane shear in its first row and second column, but that entry is zero for the ideal pinhole camera considered here.
Why represent the image point with a third coordinate and use a matrix instead of relying only on the two formulas containing division by Z? What benefit might this form provide when another transformation is introduced?
Use homogeneous coordinates for transformations
A Cartesian point (x, y) becomes (xS, yS, S) in homogeneous coordinates. Any nonzero S describes the same point because dividing the first two entries by the third recovers the Cartesian coordinates.
Homogeneous representations are therefore non-unique: multiplying every component by one nonzero scalar leaves the Cartesian point unchanged. They can also describe a direction's point at infinity. As S approaches zero, the represented point recedes without bound, and (x, y, 0) denotes the point at infinity along that direction.
In three dimensions, (X, Y, Z) has the homogeneous form (XS, YS, ZS, S). The added coordinate allows a rotation and a translation to be performed by one 4 × 4 matrix multiplication instead of two separate operations.
Here R is a 3 × 3 rotation block and t is a 3 × 1 translation block. The final row [0 0 0 1] preserves the homogeneous form.
Transform world coordinates into the camera frame
The intrinsic matrix expects camera-frame coordinates, while object locations are generally known in the world frame. The camera's world position and orientation describe its coordinate system, so those data must be converted into the transformation that acts on object coordinates.
Moving a coordinate system counterclockwise has the same effect on point coordinates as moving the points clockwise by the same amount. In general, a transformation of the coordinate frame corresponds to the inverse transformation of object coordinates. Consequently, the matrix that sends camera coordinates to world coordinates must be inverted to obtain the required world-to-camera mapping.
This inverse uses Rᵀ=R⁻¹ for the rotation. Applying it to a homogeneous world point returns that point's camera coordinates. Because an ordinary Cartesian point enters with final coordinate 1 and leaves with the same value, no rescaling is required here.
Only the first three output coordinates are needed by K, so the last row can be omitted. The remaining 3 × 4 world-to-camera transformation is the extrinsic camera matrix, commonly written [R|t], with R and t understood as the world-to-camera rotation and translation blocks.
Given a camera's world position and orientation, how would you obtain R and t for the world-to-camera mapping? In physical terms, what does a nonzero translation represent?
Combine the internal and external mappings
The extrinsic transformation first converts a world point to camera coordinates. The intrinsic matrix then turns those camera coordinates into homogeneous image coordinates. Their composition is the complete projection.
Multiplying a homogeneous world point by P produces homogeneous image coordinates. Divide the result's first and second entries by its third entry to recover the pixel coordinates. In this way, P combines the camera's internal geometry—pixel focal lengths and principal point—with its external rotation and translation.
Common misconceptions
Watch out: A larger aperture still sends light from only one direction to each sensor point.
Instead: In the pinhole explanation, enlarging the aperture lets several light directions reach one sensor location, which produces blur unless lenses reduce it.
Watch out: A Cartesian point has exactly one homogeneous representation.
Instead: Every common nonzero scaling represents the same Cartesian point, so homogeneous coordinates are not unique.
Watch out: The camera-to-world matrix can be applied directly before the intrinsic matrix.
Instead: The intrinsic matrix needs camera coordinates, so world points must use the inverse transformation: the world-to-camera, or extrinsic, matrix.
Lesson recap
- The pinhole approximation and similar triangles lead to u=fₓX/Z+u₀ and v=fᵧY/Z+v₀ for camera-frame coordinates.
- The 3 × 3 intrinsic matrix K packages the pixel focal lengths and principal-point offsets in homogeneous form.
- A world point must be moved into the camera frame before K can be applied.
- The 3 × 4 extrinsic matrix [R|t] performs the world-to-camera rotation and translation.
- The product P=K[R|t] maps a homogeneous 3D world point to homogeneous 2D image coordinates.
This construction depends on the pinhole approximation. Lens distortions are outside that model, although some can be corrected separately.