Search

Search papers and lessons

Epipolar Geometry

Level 3 · 11 min read

Epipolar geometry says a point seen in one photo must lie on a known line in the other photo, which turns a 2D search into a 1D one and links two views through a 3 by 3 matrix.

On this page

  • Colour = topic mix
  • Linear algebra
  • Computer vision
  • Discrete math
  • Sign in to see your progress

TL;DR

Two cameras looking at the same scene see the same point in different places. Epipolar geometry says the point in the second image must lie on a specific line, which is fixed by the two cameras alone. A 3 by 3 matrix encodes that rule, so matching a point across views becomes a one-dimensional search along a line.

Where you'll see it: stereo depth estimation, feature matching between photos, and the first step of structure from motion.

Intuition

Hold up two fingers, one in front of each eye, and close one eye at a time. The near finger jumps sideways far more than the far one. Now imagine you know where one fingertip is in the left view and you want to find it in the right view. You do not have to search the whole right image. The fingertip must lie somewhere along one line in the right view, because the point, the two camera centres, and that line all sit in one plane.

That plane is the key object. Take the two camera centres and the 3D point. They define a plane, called the epipolar plane. Each image cuts this plane in a line. The point appears on the line in each image, and the two lines are the epipolar lines. The point where the line from one camera centre meets the other image is the epipole, the place where the other camera appears in this image.

Why does this help? Matching is the expensive part of many vision pipelines, and searching a full image for a match is slow and error-prone. If the geometry is known, the search drops from two dimensions to one. The same geometry also lets a program reject matches that are geometrically impossible, which is useful when many matches are wrong.

flowchart LR
  P["3D point X"] --> E1["Epipolar plane through both centres and X"]
  E1 --> L1["Line l in image 1: contains x"]
  E1 --> L2["Line l' in image 2: must contain x'"]
  C1["Camera centre 1"] --> E1
  C2["Camera centre 2"] --> E1

The math

Use the Pinhole Camera Model. Put camera 1 at the origin with identity orientation, and place camera 2 by a rotation RR and a translation t\mathbf{t}. A point X\mathbf{X} written in camera 1 coordinates is written in camera 2 coordinates as X′=RX+t\mathbf{X}' = R\mathbf{X} + \mathbf{t}. Here t\mathbf{t} is the position of camera 1's centre written in camera 2's frame (camera 1's centre is X=0\mathbf{X}=\mathbf{0}, which maps to t\mathbf{t}). Write x=X/Z\mathbf{x} = \mathbf{X}/Z and x′=X′/Z′\mathbf{x}' = \mathbf{X}'/Z' for the normalised image points, with depth ZZ and Z′Z' scaling them onto the image plane at z=1z = 1.

The essential matrix

In camera 2 coordinates, the vectors t\mathbf{t}, RXR\mathbf{X} and X′=RX+t\mathbf{X}' = R\mathbf{X} + \mathbf{t} all lie in the epipolar plane. The triple product of coplanar vectors is zero. Writing [t]×[\mathbf{t}]_\times for the matrix that computes the cross product with t\mathbf{t} (so [t]×v=t×v[\mathbf{t}]_\times \mathbf{v} = \mathbf{t} \times \mathbf{v}), the coplanarity of X′\mathbf{X}', t\mathbf{t} and RXR\mathbf{X} gives

X′⊤ [t]×R X=0.\mathbf{X}'^\top \,[\mathbf{t}]_\times R\, \mathbf{X} = 0.

Since X\mathbf{X} and X′\mathbf{X}' are scalar multiples of x\mathbf{x} and x′\mathbf{x}', the scalars drop out and we get the constraint in image coordinates.

Definition: Essential matrix

For a pair of calibrated cameras with relative pose (R,t)(R, \mathbf{t}), the essential matrix is E=[t]×RE = [\mathbf{t}]_\times R. Corresponding normalised image points satisfy

x′⊤E x=0.\mathbf{x}'^\top E\, \mathbf{x} = 0.

Some facts follow directly. EE is a 3×33 \times 3 matrix with rank 2, because [t]×[\mathbf{t}]_\times has rank 2 and RR is invertible. Its two nonzero singular values are equal. It has 5 degrees of freedom: 3 from the rotation and 2 from the direction of the translation, since the length of t\mathbf{t} cannot be recovered from images alone.

The fundamental matrix

Real cameras have pixel coordinates p=Kx\mathbf{p} = K\mathbf{x}, where KK is the intrinsic matrix from the pinhole lesson. Substituting x=K−1p\mathbf{x} = K^{-1}\mathbf{p} gives the constraint in pixels.

Definition: Fundamental matrix
F=K′−⊤E K−1,p′⊤F p=0.F = K'^{-\top} E\, K^{-1}, \qquad \mathbf{p}'^\top F\, \mathbf{p} = 0.

Here KK and K′K' are the intrinsic matrices of the two cameras. FF works directly on pixel coordinates and needs no calibration.

FF is also rank 2 and defined only up to scale, so it has 7 degrees of freedom.

Epipolar lines and epipoles

Fix a point p\mathbf{p} in image 1. The set of image-2 points satisfying p′⊤Fp=0\mathbf{p}'^\top F\mathbf{p} = 0 is a line, with coefficients l′=Fp\mathbf{l}' = F\mathbf{p}. The line l′\mathbf{l}' is written as l1u+l2v+l3=0l_1 u + l_2 v + l_3 = 0 in image-2 coordinates. The match of p\mathbf{p} must lie on it. In the other direction, l=F⊤p′\mathbf{l} = F^\top \mathbf{p}' is the epipolar line in image 1 for a point p′\mathbf{p}' in image 2.

The epipoles are where all epipolar lines meet. The epipole in image 1 is the null vector e\mathbf{e} with Fe=0F\mathbf{e} = 0, and the epipole in image 2 is e′\mathbf{e}' with e′⊤F=0\mathbf{e}'^\top F = 0. Geometrically, e′\mathbf{e}' is where camera 1's centre appears in image 2.

Estimating F from matches

Each pair (p,p′)(\mathbf{p}, \mathbf{p}') gives one linear equation in the nine entries of FF. Nine unknowns up to scale need eight equations, which gives the classic eight-point algorithm. Stack the equations into a matrix AA, take the singular vector of AA with the smallest singular value, reshape it into a 3×33 \times 3 matrix, and then force rank 2 by setting the smallest singular value of that matrix to zero. Normalising the pixel coordinates before solving, as Hartley showed in 1997, is essential for numerical stability.

Recovering the pose from E

If EE is known, the SVD E=U diag(1,1,0) V⊤E = U\,\mathrm{diag}(1, 1, 0)\,V^\top gives the relative pose up to a four-way ambiguity. With W=(0−10100001)W = \begin{pmatrix} 0 & -1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{pmatrix}, the rotation is R=UWV⊤R = UWV^\top or UW⊤V⊤UW^\top V^\top, and the translation direction is ±\pm the last column of UU. Only one of the four combinations puts the triangulated points in front of both cameras, and that check resolves the ambiguity. The translation length stays unknown, so a real reconstruction fixes the scale with another measurement.

Worked examples

Example
Pure sideways motion: the lines are horizontal

Use normalised coordinates, so K=IK = I. Let camera 2 be translated sideways with no rotation: R=IR = I and t=(1,0,0)\mathbf{t} = (1, 0, 0).

  1. Write [t]×[\mathbf{t}]_\times for t=(1,0,0)\mathbf{t} = (1, 0, 0). The cross product gives t×v=(0,−v3,v2)\mathbf{t} \times \mathbf{v} = (0, -v_3, v_2), so [t]×=(00000−1010)[\mathbf{t}]_\times = \begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & -1 \\ 0 & 1 & 0 \end{pmatrix}.
  2. Since R=IR = I, E=[t]×E = [\mathbf{t}]_\times.
  3. Take the 3D point X=(1,2,4)\mathbf{X} = (1, 2, 4). In camera 1, x=(0.25,0.5,1)\mathbf{x} = (0.25, 0.5, 1).
  4. In camera 2, X′=(2,2,4)\mathbf{X}' = (2, 2, 4), so x′=(0.5,0.5,1)\mathbf{x}' = (0.5, 0.5, 1).
  5. Compute Ex=(0,−1,0.5)E\mathbf{x} = (0, -1, 0.5). This is the epipolar line in image 2, read as 0⋅u−1⋅v+0.5=00 \cdot u - 1 \cdot v + 0.5 = 0, which is v=0.5v = 0.5.
  6. Check the constraint: x′⊤(Ex)=0.5⋅0+0.5⋅(−1)+1⋅0.5=0\mathbf{x}'^\top (E\mathbf{x}) = 0.5 \cdot 0 + 0.5 \cdot (-1) + 1 \cdot 0.5 = 0. The match lies on the line.
  7. The epipole satisfies Ee=0E\mathbf{e} = 0, so e=(1,0,0)\mathbf{e} = (1, 0, 0). It is a point at infinity in the direction of t\mathbf{t}, so the epipolar lines are parallel. Every line is horizontal.

Interpretation: when the cameras move sideways, the epipolar lines are horizontal rows. A match in image 2 must sit in the same row as its partner in image 1. This is why stereo rectification rotates the images so that the epipolar lines become rows.

Example
Pixel coordinates and the distance test

Take the same sideways motion, but now the cameras have intrinsic matrix K=K′=diag(500,500,1)K = K' = \mathrm{diag}(500, 500, 1), so K−1=diag(0.002,0.002,1)K^{-1} = \mathrm{diag}(0.002, 0.002, 1). The fundamental matrix is F=K−⊤EK−1F = K^{-\top} E K^{-1}. Scaling the rows and columns of EE by 0.0020.002 where they touch the first two coordinates gives

F=(00000−0.00200.0020).F = \begin{pmatrix} 0 & 0 & 0 \\ 0 & 0 & -0.002 \\ 0 & 0.002 & 0 \end{pmatrix}.
  1. Take a pixel p=(100,50,1)\mathbf{p} = (100, 50, 1) in image 1. Compute l′=Fp=(0,−0.002,0.1)\mathbf{l}' = F\mathbf{p} = (0, -0.002, 0.1).
  2. The line is −0.002 v+0.1=0-0.002\,v + 0.1 = 0, so v=50v = 50. Every match of p\mathbf{p} lies in row 50 of image 2.
  3. A candidate match p′=(300,50,1)\mathbf{p}' = (300, 50, 1) gives p′⊤Fp=0\mathbf{p}'^\top F \mathbf{p} = 0, so it is consistent.
  4. A candidate p′=(300,58,1)\mathbf{p}' = (300, 58, 1) is off the line. The distance from a point to a line is ∣l′⋅p′∣/l12+l22|\mathbf{l}' \cdot \mathbf{p}'| / \sqrt{l_1^2 + l_2^2}. Here it is ∣−0.002⋅58+0.1∣/0.002=0.016/0.002=8|{-0.002} \cdot 58 + 0.1| / 0.002 = 0.016 / 0.002 = 8 pixels.

Interpretation: the epipolar test does not need the 3D point. It only needs FF, and it gives a distance in pixels. A RANSAC step that keeps matches within a few pixels of their epipolar lines removes most wrong matches without knowing the scene.

Tradeoffs and failure modes

Epipolar geometry is exact for a rigid scene viewed by two pinhole cameras. Its weaknesses come from what it assumes.

SituationWhat goes wrongBetter choice
Moving objects in the sceneMatches on moving objects violate the rule and are rejectedRobust estimation with RANSAC, or a motion-aware model
Points that lie on one planeThe eight-point system becomes degenerate and FF is not uniqueHomography for planar scenes, or a model with more views
Pure rotation of the cameraThe baseline is zero, so the epipolar lines do not constrain depthUse the homography between views, or ignore depth
Noisy or poorly spread matchesThe rank-2 projection is unstable, and FF shifts badlyNormalise coordinates, use RANSAC, then refine nonlinearly
Only the rotation and direction of motion neededFull FF has extra parametersEssential matrix EE with known intrinsics

A common mistake is to use the essential matrix when the cameras are uncalibrated. EE needs known KK. Without calibration, use FF and accept that the pose is only known up to a projective transformation.

History

Christopher Longuet-Higgins published a method in 1981 for recovering the relative pose of two views from eight point correspondences, which is the first form of the essential matrix. Later work by Olivier Faugeras and by Quang-Tuan Luong in the early 1990s introduced the fundamental matrix for uncalibrated cameras. Richard Hartley showed in 1997 that normalising the coordinates makes the eight-point algorithm reliable, and the approach became the standard starting point for two-view reconstruction. Hartley and Andrew Zisserman's textbook on multiple-view geometry collected these results and is the usual reference.

Check yourself

QuestionWhy does the essential matrix have rank 2 rather than rank 3?Show answer

It is the product [t]×R[\mathbf{t}]_\times R. The cross-product matrix [t]×[\mathbf{t}]_\times has rank 2, because its null space is the direction t\mathbf{t} itself. Multiplying by an invertible rotation RR keeps the rank at 2. Geometrically, ExE\mathbf{x} is always an epipolar line, and all epipolar lines pass through the epipole, so the outputs of EE fill only a 2-dimensional space.

QuestionA fundamental matrix gives the epipolar line l′=(1,2,−6)\mathbf{l}' = (1, 2, -6) in image 2 for a point in image 1. Which of the points (2,2)(2, 2) and (4,1)(4, 1) could be its match, if the match must lie on the line u+2v−6=0u + 2v - 6 = 0?Show answer

Check each point in the line equation. For (2,2)(2, 2): 2+4−6=02 + 4 - 6 = 0, so it lies on the line and could be the match. For (4,1)(4, 1): 4+2−6=04 + 2 - 6 = 0, so it also lies on the line. Both are consistent with the geometry, and the epipolar constraint alone cannot choose between them. Another cue, such as the appearance of the patch around each point, is needed to decide.

QuestionWhy can the essential matrix give the translation direction but not its length?Show answer

The constraint x′⊤[t]×R x=0\mathbf{x}'^\top [\mathbf{t}]_\times R\,\mathbf{x} = 0 depends only on the direction of t\mathbf{t}. Scaling t\mathbf{t} by any positive number leaves the constraint unchanged. A bigger baseline and a farther scene can produce the same image pair, so the images carry no information about the length. A known distance, such as a measured baseline or a known object size, is needed to set the scale.

QuestionApplied: you are building a stereo matcher for two rectified photos from a camera with a 60 mm baseline. Why does rectification make the search easier, and what do you check first?Show answer

Rectification rotates both images so that the epipolar lines become horizontal rows, and each point's match lies in the same row of the other image. The search drops from two dimensions to one, along a short horizontal range. Before relying on it, check that the rectification is accurate: a vertical error of even one or two pixels pushes matches off their rows and makes the disparity search fail. Verify that matched features sit on the same row to within that tolerance.

Sources