Geometry & 3D Vision

Projective Geometry

The geometry of properties that survive perspective projection, such as straightness, incidence, and the cross-ratio, which underlies how computer vision models cameras and relates images.

intermediate

Projective geometry studies the properties of figures that are preserved by projective transformations, the maps that a camera’s central projection produces between planes. Under perspective, lengths, angles, and parallelism are lost, as anyone who has photographed railway tracks knows, but straight lines stay straight, lines that meet still meet, and one number built from four collinear points, the cross-ratio, does not change. Computer vision uses projective geometry because image formation is a projective map: it explains vanishing points and the horizon, organizes the hierarchy of 2D and 3D transformations, and tells what can be recovered from images with and without knowledge of the camera.

Definition

The projective plane P2\mathbb{P}^2 is the set of non-zero 3-vectors up to scale, that is, the points of the plane in homogeneous coordinates together with the points at infinity. Projective space P3\mathbb{P}^3 is defined the same way with 4-vectors. A projective transformation, also called a projectivity, collineation, or homography, is an invertible map of Pn\mathbb{P}^n that sends lines to lines; algebraically, every such map is multiplication of the homogeneous vectors by an invertible (n+1)×(n+1)(n+1) \times (n+1) matrix (Hartley and Zisserman, 2004, §2.3). Projective geometry is the study of properties invariant under these maps.

Intuition

Draw a square grid on a flat floor and photograph it at an angle. The squares become quadrilaterals of shrinking size, the parallel lines converge toward points, and those points all lie on one line, the horizon. Yet the image is not arbitrary: straight lines stay straight, and points in a row stay in a row, in the same order.

Projective geometry makes this precise by adding the points where parallel lines would meet. Once the plane includes these points at infinity, two lines always meet in exactly one point, and the line formed by the points at infinity is no different from any other line. A projective transformation can map it to an ordinary line, and that is what a camera does when the horizon appears in a photograph.

Formal Definition

Projective transformations

A projective transformation of the plane is

x′∼Hx,H∈R3×3,  det⁡H≠0,\mathbf{x}' \sim \mathbf{H}\mathbf{x}, \qquad \mathbf{H} \in \mathbb{R}^{3 \times 3}, \; \det \mathbf{H} \neq 0,

where ∼\sim means equality up to a non-zero scale. Since H\mathbf{H} and kHk\mathbf{H} give the same map, a planar homography has 8 degrees of freedom, and four point correspondences, no three of them collinear, determine it. A line transforms as l′∼H−⊤l\mathbf{l}' \sim \mathbf{H}^{-\top}\mathbf{l}, which keeps incidence l⊤x=0\mathbf{l}^\top\mathbf{x} = 0 intact. In P3\mathbb{P}^3, projective transformations are invertible 4×44 \times 4 matrices with 15 degrees of freedom.

The hierarchy of transformations

Restricting H\mathbf{H} gives a nested family of groups. Hartley and Zisserman (2004, §2.4) organize them by degrees of freedom and by the properties each preserves; each group also preserves the invariants listed in the rows above it:

Group Matrix form DOF New invariants
Projective general invertible H\mathbf{H} 8 collinearity, incidence and concurrency, the cross-ratio
Affine last row (0,0,1)(0, 0, 1) 6 parallelism, ratios of lengths on collinear or parallel lines, ratios of areas, the line at infinity
Similarity scaled rotation sRs\mathbf{R} and translation t\mathbf{t}, last row (0,0,1)(0, 0, 1) 4 angles, ratios of lengths, the circular points
Euclidean rotation R\mathbf{R} and translation t\mathbf{t}, last row (0,0,1)(0, 0, 1) 3 lengths, areas

Read from the bottom up, each row gives up some invariants in exchange for more freedom. Szeliski (2022, §2.1) presents the same planar hierarchy, with translation as a further 2-DOF level, and the matrices are written out in image warping. The 3D hierarchy is analogous, with 15, 12, 7, and 6 degrees of freedom and the plane at infinity in the role of the line at infinity (Hartley and Zisserman, 2004, §3.4).

The cross-ratio

For four collinear points with signed positions tA,tB,tC,tDt_A, t_B, t_C, t_D along their line, the cross-ratio is

(A,B;C,D)=(tC−tA)(tD−tB)(tC−tB)(tD−tA).(A, B; C, D) = \frac{(t_C - t_A)(t_D - t_B)}{(t_C - t_B)(t_D - t_A)}.

It is unchanged by any projective transformation, and it is the fundamental invariant of the projective line (Hartley and Zisserman, 2004, §2.5): an ordinary ratio of lengths is preserved by affine maps but not projective ones, while the cross-ratio, a ratio of ratios, survives. Different orderings of the four points give different but related values, and texts differ in which ordering they call the cross-ratio.

Duality

In P2\mathbb{P}^2, points and lines are both homogeneous 3-vectors, and incidence l⊤x=0\mathbf{l}^\top\mathbf{x} = 0 is symmetric in them. Every theorem about points and lines therefore has a dual, obtained by exchanging the words “point” and “line” and “lies on” and “passes through” (Hartley and Zisserman, 2004, §2.2). The intersection of two lines is dual to the line through two points. In P3\mathbb{P}^3, points are dual to planes.

Conics

A conic is the curve of points satisfying x⊤Cx=0\mathbf{x}^\top\mathbf{C}\mathbf{x} = 0 for a symmetric 3×33 \times 3 matrix C\mathbf{C}; it has 5 degrees of freedom, so five points in general position determine it. Under a homography a conic maps to a conic, C′∼H−⊤CH−1\mathbf{C}' \sim \mathbf{H}^{-\top}\mathbf{C}\mathbf{H}^{-1}, which is why the image of a circle on a plane is an ellipse, parabola, or hyperbola. Projectively, all non-degenerate conics with real points are equivalent to a circle; the distinction between the three types depends on how the conic meets the line at infinity, an affine notion.

Properties

Vanishing points and the horizon

The points at infinity of a scene are not visible, but their images usually are. All lines with direction d\mathbf{d} in space share the point at infinity (d⊤,0)⊤(\mathbf{d}^\top, 0)^\top, so their images pass through one image point, the vanishing point of that direction. For a camera with intrinsic matrix K\mathbf{K} and rotation R\mathbf{R}, the vanishing point is v∼KRd\mathbf{v} \sim \mathbf{K}\mathbf{R}\mathbf{d}, independent of camera position (Hartley and Zisserman, 2004, §8.6). The vanishing points of all directions parallel to a scene plane lie on a line, the vanishing line of the plane, which is the image of the plane’s line at infinity; for the ground plane it is the horizon.

From projective to metric: the absolute conic

Metric properties are projective properties relative to special objects at infinity. In the plane, every circle passes through the two complex circular points (1,±i,0)⊤(1, \pm i, 0)^\top on the line at infinity; fixing the line at infinity recovers affine geometry, and fixing the circular points as well recovers angles and length ratios, that is, similarity geometry. In space, all spheres meet the plane at infinity in the same complex conic, the absolute conic. Its image depends only on the camera’s intrinsic parameters, which connects it to camera calibration (Hartley and Zisserman, 2004, §2.7, §3.6, and §8.5).

Why vision needs it

Perspective projection by a pinhole camera is a linear map from P3\mathbb{P}^3 to P2\mathbb{P}^2, a 3×43 \times 4 matrix. Two images of a plane, or two images taken by a camera rotating about its center, are related by a 3×33 \times 3 homography. Faugeras (1995) organized what two uncalibrated views reveal about 3D structure into three nested strata. The epipolar geometry alone gives structure up to a projective transformation of space; adding the homography induced by the plane at infinity gives affine structure, and adding the images of the absolute conic gives metric structure, Euclidean up to an overall scale. Hartley and Zisserman (2004, §1.7–1.8, §10.4) present reconstruction the same way: knowing the camera calibration amounts to knowing the image of the absolute conic, and auto-calibration finds it from constraints such as constant or partly known intrinsic parameters.

History

Girard Desargues’s 1639 treatise on conic sections treated parallel lines as meeting at a point at infinity, but it was long neglected. Jean-Victor Poncelet’s Traité des propriétés projectives des figures (1822) established the study of properties preserved by projection as a subject in its own right. In computer vision, projective invariants such as the cross-ratio were developed as a basis for recognizing objects independently of viewpoint, a line of work collected by Mundy and Zisserman (1992).

Examples

The code maps four collinear points by a random homography with perspective terms, checks that they stay collinear, and compares the cross-ratio with an ordinary ratio of lengths. It then maps the point at infinity of a direction to its vanishing point and checks that the images of three parallel lines pass through it.

import numpy as np

rng = np.random.default_rng(0)


def apply(H, pts):
    """Map Cartesian points (N x 2) by a 3x3 homography, dividing by the last coordinate."""
    ph = np.c_[pts, np.ones(len(pts))] @ H.T
    return ph[:, :2] / ph[:, 2:]


def cross_ratio(a, b, c, d):
    """(A,B;C,D) = (AC * BD) / (BC * AD), with signed distances along the line."""
    u = (b - a) / np.linalg.norm(b - a)          # unit direction of the line
    t = [np.dot(p - a, u) for p in (a, b, c, d)]  # 1D coordinates along it
    ta, tb, tc, td = t
    return ((tc - ta) * (td - tb)) / ((tc - tb) * (td - ta))


# Four collinear points on the line through (1, 2) with direction (3, 1).
p0, d = np.array([1.0, 2.0]), np.array([3.0, 1.0])
pts = np.array([p0 + s * d for s in (0.0, 1.0, 2.5, 4.0)])

# A random homography: identity plus a perturbation that includes perspective terms.
H = np.eye(3) + 0.3 * rng.standard_normal((3, 3))
H[2, :2] = 0.02 * rng.standard_normal(2)
print("H =\n", np.round(H, 3))
img = apply(H, pts)

# The images are still collinear: the 2D cross products of the differences are ~0.
e = img[1:] - img[0]
print("collinear after mapping:", np.allclose(e[0, 0] * e[1:, 1] - e[0, 1] * e[1:, 0], 0))
print("third coordinates (all > 0, no point crosses the line at infinity):",
      np.round(np.c_[pts, np.ones(4)] @ H[2], 3))

def length_ratio(p):
    return np.linalg.norm(p[1] - p[0]) / np.linalg.norm(p[2] - p[1])

print(f"cross-ratio  before {cross_ratio(*pts):.6f}  after {cross_ratio(*img):.6f}")
print(f"|AB|/|BC|    before {length_ratio(pts):.6f}  after {length_ratio(img):.6f}")

# An affine map (last row 0 0 1) keeps ratios of lengths along a line.
A = H.copy(); A[2] = [0, 0, 1]
print(f"|AB|/|BC| under the affine part: {length_ratio(apply(A, pts)):.6f}")

# Parallel world lines: a homography maps their common point at infinity to a
# finite vanishing point, where the images of the lines meet.
v_inf = np.array([3.0, 1.0, 0.0])                # direction (3, 1) as a point at infinity
v = H @ v_inf
print("vanishing point of direction (3,1):", np.round(v[:2] / v[2], 4))
for offset in [(0.0, 0.0), (0.0, 5.0), (2.0, -3.0)]:
    q0 = p0 + np.array(offset)
    a, b = apply(H, np.array([q0, q0 + 10 * d]))
    line = np.cross([*a, 1], [*b, 1])            # image of one of the parallel lines
    print(f"  image line through offset {offset}: line . v = {line @ v:+.2e}")

Output:

H =
 [[ 1.038 -0.04   0.192]
 [ 0.031  0.839  0.108]
 [-0.025 -0.012  0.789]]
collinear after mapping: True
third coordinates (all > 0, no point crosses the line at infinity): [0.739 0.65  0.518 0.385]
cross-ratio  before 1.250000  after 1.250000
|AB|/|BC|    before 0.666667  after 0.467222
|AB|/|BC| under the affine part: 0.666667
vanishing point of direction (3,1): [-34.772  -10.5634]
  image line through offset (0.0, 0.0): line . v = -3.72e-14
  image line through offset (0.0, 5.0): line . v = -1.67e-14
  image line through offset (2.0, -3.0): line . v = -1.77e-14

The four points stay collinear, and their cross-ratio is 1.25 before and after the mapping, to six decimal places, while the ratio ∣AB∣/∣BC∣|AB|/|BC| changes from 0.667 to 0.467. Removing the perspective row leaves an affine map, which preserves the length ratio. The point at infinity (3,1,0)⊤(3, 1, 0)^\top maps to the finite vanishing point (−34.77,−10.56)(-34.77, -10.56), and the images of three different parallel lines with direction (3,1)(3, 1) all pass through it, up to rounding.

Common Misconceptions

  • “Projective transformations can bend lines.” They cannot: preserving lines is their defining property. Curved images of straight edges come from lens distortion, which is not projective and must be corrected before projective tools apply.
  • “Points at infinity are a limit, not real points.” In P2\mathbb{P}^2 they are ordinary points, and a homography can move them to finite positions, as vanishing points show. Only once a line at infinity is singled out do they become special, which is what affine geometry does.
  • “A projective reconstruction is a noisy metric one.” It is exact up to an unknown 4×44 \times 4 transformation that can distort angles and parallelism arbitrarily. Reaching metric structure requires additional information about the cameras or the scene, not more accuracy.
  • “The cross-ratio is one fixed number for four points.” Its value depends on the order of the points, and conventions differ between texts; any one ordering is invariant.

Where It Is Used

  • Camera models. The pinhole camera model is a projective map from 3D to 2D, factored into intrinsic and extrinsic camera parameters.
  • Homographies and image warping. The homography between two views of a plane, or between images from a rotating camera, is the planar projective transformation; it drives rectification of planar surfaces, panorama stitching, and image warping.
  • Calibration from vanishing points. Vanishing points of orthogonal scene directions give linear constraints on the image of the absolute conic, so for a camera with zero skew and square pixels, which leaves three unknowns, the vanishing points of three mutually orthogonal directions, as in images of buildings or rooms, determine the focal length and principal point, provided all three are finite (Hartley and Zisserman, 2004, §8.8).
  • Multiple view geometry. Epipolar geometry, the fundamental matrix, triangulation, and stratified reconstruction are all formulated in projective terms.
  • Invariant-based recognition and measurement. Cross-ratios and other projective invariants allow measurements and comparisons that do not depend on the viewpoint, such as transferring positions along a line from one image to another (Mundy and Zisserman, 1992).

Related

  • Pinhole Camera Model

    The ideal camera in which every scene point projects through a single center onto an image plane, giving the perspective projection x = fX/Z, y = fY/Z.

  • Camera Intrinsic and Extrinsic Parameters

    The parameters of the pinhole camera matrix P = K[R | t], split into intrinsics K, which map camera coordinates to pixels, and extrinsics R and t, which place the camera in the world.

  • Image Warping

    Transforming the geometry of an image by a coordinate mapping, usually computed by sampling the input image at the inverse-mapped position of every output pixel.

  • Lens Distortion

    The systematic deviation of a real lens from the pinhole model's straight-line projection, which bends straight lines in the image and is modeled, estimated, and removed as part of camera calibration.

References

  1. Hartley, R. & Zisserman, A. (2004). Multiple View Geometry in Computer Vision (2nd ed.). Cambridge University Press.
  2. Faugeras, O. (1995). Stratification of Three-Dimensional Vision: Projective, Affine, and Metric Representations. Journal of the Optical Society of America A, 12(3), 465–484.
  3. Mundy, J. L. & Zisserman, A. (Eds.) (1992). Geometric Invariance in Computer Vision. MIT Press.
  4. Szeliski, R. (2022). Computer Vision: Algorithms and Applications (2nd ed.). Springer.