Geometry & 3D Vision
Epipolar Geometry
The geometry of two views of the same scene, in which the two camera centers and any scene point span a plane, so that a point in one image can only match points on a single line in the other.
intermediate
Epipolar geometry is the geometry of two views of the same scene. It depends only on the two cameras, their intrinsic parameters and their relative position and orientation, and not on what the scene contains (Hartley and Zisserman, 2004). Its central consequence is the epipolar constraint: the match of a point in one image must lie on a known line in the other image. That turns the search for correspondences from a two-dimensional problem into a one-dimensional one, and it is the basis of stereo matching, of robust verification of feature matches, and of recovering camera motion from images. This article covers the geometry; its algebraic form for uncalibrated cameras is the fundamental matrix, and for calibrated cameras the essential matrix.
Definition
Two cameras with centers and observe a scene point , which appears at in the first image and in the second.
- The baseline is the line through the two camera centers.
- An epipolar plane is any plane that contains the baseline. The plane through , , and is the epipolar plane of .
- The epipoles and are the points where the baseline meets the two image planes. Equivalently, is the image of the second camera center in the first view, and is the image of the first camera center in the second view.
- An epipolar line is the intersection of an epipolar plane with an image plane. The epipolar line of is the image in the second view of the ray that back-projects from .
The epipolar constraint states that lies on , and symmetrically that lies on the epipolar line of .
Intuition
A pixel in the first image does not say how far away its scene point is. All it fixes is a ray from the first camera center through that pixel, and the point can be anywhere along that ray. Seen from the second camera, this ray is a line in the image, starting at the image of the first camera center (the epipole) and extending toward the image of the ray’s point at infinity. Wherever the scene point actually is, its image in the second view lies somewhere on that line.
The two rays through a correct match meet at the scene point, so they lie in one plane together with the baseline. This plane is the epipolar plane. As the scene point varies, the epipolar plane rotates about the baseline like the pages of a book about its spine, and its intersections with each image sweep out a family of lines, the pencil of epipolar lines, all passing through the epipole.
Formal Definition
The notation here is shared with the fundamental matrix and essential matrix articles. Image points are homogeneous 3-vectors: in the first image and in the second. The first camera defines the world frame, and the cameras are
so that a point in first-camera coordinates has coordinates in the second camera’s frame (the world-to-camera convention of camera parameters). The second camera center is . Normalized coordinates are and . is the skew-symmetric matrix with .
The epipoles are the images of the other camera’s center:
each defined up to scale. The epipolar line of in the second image joins to the image of any other point on the back-projected ray, for example the point at infinity in direction , whose image is :
In homogeneous coordinates a point lies on a line when their dot product vanishes, so the epipolar constraint is
Since depends linearly on , the constraint can be written as one bilinear equation, , with a matrix : the fundamental matrix, with , , and . In normalized coordinates the same constraint reads with the essential matrix , which expresses directly that the two rays and the baseline are coplanar. Longuet-Higgins (1981) introduced this algebraic form for calibrated cameras to computer vision.
Properties
- All epipolar lines pass through the epipole. Every epipolar plane contains the baseline, so every epipolar line contains the baseline’s intersection with the image. Algebraically, for every .
- Epipolar lines come in corresponding pairs. One epipolar plane cuts both images, so each epipolar line in one image has exactly one partner in the other, and all points on map to points on . Hartley and Zisserman (2004, §9.2.5) show that the two pencils of lines are related by a one-dimensional projective transformation.
- The constraint is necessary, not sufficient. A point anywhere on satisfies it, so it rejects many wrong matches but cannot certify a right one. It also says nothing about a point whose true match is occluded.
- The epipole may be anywhere. It lies inside the image when the other camera center projects into the image, as under forward motion, outside it for typical side-by-side configurations, and at infinity when the baseline is parallel to the image plane.
- No baseline, no epipolar geometry. If the two centers coincide, as for a camera rotating about its center, there is no baseline and no epipolar plane. The views are then related by a homography instead, which maps each point to a single point rather than a line.
Special configurations
Two motions give epipolar geometry a particularly simple form, both described by Hartley and Zisserman (2004, §9.1, §9.3).
Parallel cameras. When the second camera is shifted sideways along the first camera’s -axis, with no rotation and equal intrinsics, the baseline is parallel to both image planes. The epipoles are at infinity in the direction, and the epipolar lines are horizontal and identical in both images: the match of a pixel lies in the same row of the other image. This is the configuration that stereo rectification creates artificially.
Forward motion. When a camera translates without rotating and its intrinsics stay the same, the epipole has the same coordinates in both images. As the camera advances, image points move away from the epipole along radial lines, so the epipole is the focus of expansion, the point from which the motion field appears to radiate. If the motion is along the optical axis, it is at the principal point.
Relation to homographies
When all scene points lie on one plane, the plane induces a homography with , and the epipolar line of is the line through and . Hartley and Zisserman (2004, §9.2) use this construction to derive the fundamental matrix as . The reverse does not work: from points on a single plane, or from a purely rotating camera, the epipolar geometry cannot be recovered, because the correspondences satisfy a homography and are consistent with many different epipolar geometries. These are the main degenerate cases for estimating the fundamental matrix.
Examples
The NumPy code below sets up two pinhole cameras and builds epipolar lines geometrically, without any fundamental matrix: it back-projects each pixel of the first image to a ray, images two points of that ray in the second camera (the first camera center, which gives the epipole, and a point at unit depth), and joins them. It then checks that each true match lies on its line and that all lines pass through the epipole, for a general motion, a sideways shift, and a forward motion.
import numpy as np
from scipy.spatial.transform import Rotation
np.set_printoptions(precision=3, suppress=True)
rng = np.random.default_rng(0)
K = np.array([[800.0, 0, 320], [0, 800.0, 240], [0, 0, 1]])
def camera(R, t):
"""P = K [R | t]; camera 1 is P = K [I | 0]."""
return K @ np.hstack([R, t[:, None]])
def project(P, X):
x = np.hstack([X, np.ones((len(X), 1))]) @ P.T
return x / x[:, 2:]
def epipolar_lines(P1, P2, x1):
"""Epipolar lines in image 2, built geometrically: back-project each x1
to a ray, image two points of the ray (the camera-1 centre and a point
at depth 1) in camera 2, and join them with a cross product."""
C1 = np.array([0.0, 0, 0, 1]) # centre of camera 1
e2 = P2 @ C1 # its image: the epipole e'
d = np.linalg.solve(K, x1.T).T # ray directions (depth 1)
p2 = np.hstack([d, np.ones((len(d), 1))]) @ P2.T # image of a ray point
return e2, np.cross(e2, p2) # line through e' and it
def dist(lines, x):
return np.abs(np.sum(lines * x, 1)) / np.hypot(lines[:, 0], lines[:, 1])
X = rng.uniform([-2, -2, 4], [2, 2, 8], size=(6, 3)) # scene points
P1 = camera(np.eye(3), np.zeros(3))
setups = {
"general": (Rotation.from_euler("y", -10, degrees=True).as_matrix(),
np.array([-1.0, 0.1, 0.2])),
"parallel": (np.eye(3), np.array([-0.5, 0.0, 0.0])), # sideways shift
"forward": (np.eye(3), np.array([0.0, 0.0, -1.0])), # move along the axis
}
for name, (R, t) in setups.items():
P2 = camera(R, t)
x1, x2 = project(P1, X), project(P2, X)
e2, l2 = epipolar_lines(P1, P2, x1)
if abs(e2[2]) > 1e-12:
print(f"{name}: epipole e' at pixel {e2[:2] / e2[2]}")
else:
print(f"{name}: epipole e' at infinity in direction {e2[:2] / np.linalg.norm(e2[:2])}")
print(" max distance of x' to its epipolar line (px):", f"{dist(l2, x2).max():.1e}")
print(" max |l' . e'| (lines pass through e', algebraic):", f"{np.abs(l2 @ e2).max():.1e}")
if name == "parallel":
print(" max |a| / |b| over lines ax + by + c = 0:", f"{np.max(np.abs(l2[:, 0] / l2[:, 1])):.1e}")
Output:
general: epipole e' at pixel [-3680. 640.]
max distance of x' to its epipolar line (px): 7.4e-14
max |l' . e'| (lines pass through e', algebraic): 6.7e-12
parallel: epipole e' at infinity in direction [-1. 0.]
max distance of x' to its epipolar line (px): 9.1e-15
max |l' . e'| (lines pass through e', algebraic): 0.0e+00
max |a| / |b| over lines ax + by + c = 0: 0.0e+00
forward: epipole e' at pixel [320. 240.]
max distance of x' to its epipolar line (px): 1.4e-13
max |l' . e'| (lines pass through e', algebraic): 1.5e-11
Every match lies on its epipolar line to rounding error. In the general case the epipole is far outside the 640 × 480 image, as is typical when the cameras are side by side. The sideways shift puts the epipole at infinity and makes every epipolar line horizontal (), and moving forward along the optical axis puts the epipole at the principal point , the focus of expansion.
Common Misconceptions
- “The epipolar line tells you where the match is.” It tells you where the match can be. Finding it along the line still requires comparing image content, which is the job of stereo matching or descriptor matching.
- “Epipoles are inside the image.” Often they are not. For a nearly parallel stereo pair they are far outside or at infinity, which is why rectification algorithms must handle epipoles at infinity.
- “Epipolar lines are horizontal.” Only after rectification, or for cameras that happen to be exactly parallel. In general they converge at the epipole.
- “Any two views have an epipolar geometry that can be estimated.” Two views from the same center have none, and views of a single plane do not determine it, even though their point correspondences are perfectly consistent.
- “The epipolar geometry depends on the scene.” It depends only on the cameras. The scene supplies the correspondences from which it is estimated, but a different scene seen by the same two cameras has the same epipoles and epipolar lines.
Where It Is Used
- Stereo matching. In stereo vision, the two images are usually rectified first, warped by a homography each so that epipolar lines become corresponding image rows (Hartley and Zisserman, 2004, §11.12). Stereo matching then searches only along a row, and the offset of the match is the disparity, from which depth follows by triangulation.
- Outlier rejection in feature matching. In feature matching, putative matches between two views of a 3D scene are verified by estimating the fundamental or essential matrix with RANSAC and discarding matches that lie far from their epipolar lines. Guided matching then searches for further matches in a narrow band around each epipolar line.
- Relative pose and structure from motion. For calibrated cameras the essential matrix yields the rotation and the direction of translation between two views, the starting point of two-view reconstruction, visual odometry, and structure-from-motion pipelines.
- Motion analysis. For a translating camera, the epipole is the focus of expansion, which gives the direction of travel and constrains the optical flow to radial lines.
Related
- Fundamental Matrix
The rank-2 3 × 3 matrix F that encodes the epipolar geometry of two uncalibrated views through the constraint x'ᵀFx = 0, and how it is estimated from point correspondences.
- Essential Matrix
The 3 × 3 matrix E = [t]×R that encodes the relative rotation and translation direction between two calibrated views, how it is estimated from point matches, and how the camera pose is recovered from it.
- Stereo Vision
Recovering depth from two images taken by cameras with a known relative pose, by measuring how far each point shifts between the views.
- Feature Matching
Finding corresponding keypoints between two or more images of the same scene, from descriptor nearest-neighbor search to learned matchers.
- Homography
An invertible projective transformation of the plane, a 3×3 matrix defined up to scale, that relates two images of a planar scene or two images taken by a camera rotating about its center.
- Triangulation
Recovering the 3D position of a point from its projections in two or more images taken by cameras whose calibration and poses are known.
References
- Hartley, R. & Zisserman, A. (2004). Multiple View Geometry in Computer Vision (2nd ed.), Chapter 9: Epipolar Geometry and the Fundamental Matrix, and Section 11.12: Image rectification. Cambridge University Press.
- Longuet-Higgins, H. C. (1981). A Computer Algorithm for Reconstructing a Scene from Two Projections. Nature, 293(5828), 133–135.