Focal length, FOV & orthographic projection

The focal length decides how much of the scene a camera sees. Change it, compare perspective projection with its two simplifications, weak perspective and orthographic projection, and try the dolly zoom: the subject keeps its size while the background seems to move.

Side view true scale; wedge: vertical field of view, red: projection rays
Camera image 640 × 480 px; dashed: the model under “compare with”

Focal length and field of view

The sensor has a fixed size HH. The farther it is behind the center of projection, the narrower the cone of rays that reaches it. The angular field of view is

AFOV=2arctan⁡H2f\mathrm{AFOV} = 2 \arctan \frac{H}{2f}

with HH and ff in the same units. For a given sensor size, a shorter focal length gives a wider field of view: a 24 mm high sensor sees 27° vertically with f=50f = 50 mm and 90° with f=12f = 12 mm. The horizontal field of view uses the sensor width instead. In the camera matrix KK, ff is measured in pixels: the focal length in mm divided by the pixel size, as in the pinhole camera demo.

Perspective projection

With the camera at the origin and the principal point at (0,0)(0, 0), perspective projection is

w[uv1]=[f0000f000010][XcYcZc1],w=Zcw \begin{bmatrix} u \\ v \\ 1 \end{bmatrix} = \begin{bmatrix} f & 0 & 0 & 0 \\ 0 & f & 0 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} \begin{bmatrix} X_c \\ Y_c \\ Z_c \\ 1 \end{bmatrix}, \qquad w = Z_c

Every point is divided by its own depth: far objects look small, and parallel lines meet at vanishing points. In the side view, every projection ray passes through the camera center. On the real sensor behind the center the image is upside down, U=−X⋅f/ZU = -X \cdot f / Z; as in the pinhole camera demo, the matrices here describe the upright image on a virtual plane in front of it.

Weak perspective (scaled orthographic)

If the object's dimensions are small compared to its distance from the camera, all its points have about the same depth. Weak perspective replaces every depth by one reference depth s=Z0s = Z_0, here the distance DD of the subject:

w[uv1]=[f0000f00000s][XcYcZc1],w=sw \begin{bmatrix} u \\ v \\ 1 \end{bmatrix} = \begin{bmatrix} f & 0 & 0 & 0 \\ 0 & f & 0 & 0 \\ 0 & 0 & 0 & s \end{bmatrix} \begin{bmatrix} X_c \\ Y_c \\ Z_c \\ 1 \end{bmatrix}, \qquad w = s

Now (u,v)=fs(Xc,Yc)(u, v) = \frac{f}{s} (X_c, Y_c): the object is projected parallel to the optical axis onto the plane Zc=sZ_c = s and then scaled as a whole. The mapping is linear, parallel lines stay parallel, and a point at depth Z0+ΔZZ_0 + \Delta Z is placed with a relative error of about ΔZ/Z0\Delta Z / Z_0. The object as a whole still gets smaller when it moves away, because ss grows with its distance.

Orthographic projection

Orthographic or parallel projection is the limit where the center of projection is infinitely far from the image plane. All projection rays are parallel to the optical axis:

w[uv1]=[100001000001][XcYcZc1],w=1w \begin{bmatrix} u \\ v \\ 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} X_c \\ Y_c \\ Z_c \\ 1 \end{bmatrix}, \qquad w = 1

so (u,v)=(Xc,Yc)(u, v) = (X_c, Y_c), and the depth has no effect at all, not even the depth of the object as a whole. The last row must be [0 0 0 1][0\ 0\ 0\ 1]: with [0 0 1 0][0\ 0\ 1\ 0], ww would be ZcZ_c again, which is perspective projection with f=1f = 1. Weak perspective is orthographic projection followed by a uniform scaling by f/sf / s.

The dolly zoom

An object of size SS at distance DD appears f S/Df\,S / D pixels tall. Moving the camera away while zooming in with f∝Df \propto D keeps the subject the same size, but everything behind it changes: the background grows and seems to move closer, a trick known from film. As DD grows, the depth differences within the scene become small compared to DD, and perspective projection turns into weak perspective. This is why long telephoto shots from far away look “flat”.

About this demo. The camera looks at the center of the purple cube from distance DD, turned by 20° and tilted down by 10°, and moves along its viewing direction. The sensor has an aspect ratio of 4:3 and is HH high. The orthographic image, whose (u,v)(u, v) are in meters, is drawn at a fixed 125 px per meter.

Try this