8-point algorithm

The fundamental matrix FF can be estimated from matching points alone, without knowing anything about the cameras. Every correspondence gives one linear equation, and eight of them determine FF. Add noise, turn normalization and the rank-2 constraint on and off, and compare the estimated epipolar lines with the true ones.

Image 0 click a point to select it
Image 1 epipolar lines of F^\hat F true lines epipole: dot e^\hat e, ring ee
Singular values σk\sigma_k of AA (log scale; the red one belongs to the solution ff)

One equation per correspondence

Corresponding points x0=(u0,v0,1)⊤x_0 = (u_0, v_0, 1)^\top and x1=(u1,v1,1)⊤x_1 = (u_1, v_1, 1)^\top satisfy the epipolar constraint x1⊤Fx0=0x_1^\top F x_0 = 0. Written out, this is a linear equation in the nine entries of FF:

u1u0f11+u1v0f12+u1f13+v1u0f21+v1v0f22+v1f23+u0f31+v0f32+f33=0u_1 u_0 f_{11} + u_1 v_0 f_{12} + u_1 f_{13} + v_1 u_0 f_{21} + v_1 v_0 f_{22} + v_1 f_{23} + u_0 f_{31} + v_0 f_{32} + f_{33} = 0

Each of the nn correspondences adds one row to a homogeneous system:

[u1u0u1v0u1v1u0v1v0v1u0v01⋮⋮]⏟A  (n×9)[f11f12⋮f33]⏟f=0\underbrace{\begin{bmatrix} u_1 u_0 & u_1 v_0 & u_1 & v_1 u_0 & v_1 v_0 & v_1 & u_0 & v_0 & 1 \\ \vdots & & & & & & & & \vdots \end{bmatrix}}_{A \;(n \times 9)} \underbrace{\begin{bmatrix} f_{11} \\ f_{12} \\ \vdots \\ f_{33} \end{bmatrix}}_{f} = 0

FF has 9 entries but is only defined up to scale, which leaves 8 unknowns. So at least 8 correspondences are needed, with linearly independent rows. With more points and noise there is no exact solution, and the unit vector ff that makes ∣Af∣|Af| smallest is the right singular vector of the smallest singular value, the last column of VV in the SVD A=UΣV⊤A = U \Sigma V^\top. This is the same step as for a homography and for the projection matrix in DLT calibration.

Normalize the coordinates first

In pixel coordinates the columns of AA have very different sizes: u1u0u_1 u_0 is around 10510^5, while the last column is 1. The least-squares solution minimizes an algebraic error in which the large terms dominate, and the small singular values of AA that decide the solution get lost next to the large ones. The result is very sensitive to noise.

The fix is to change the coordinate system of each image before building AA: move the origin to the centroid of the points and scale them so that their mean distance from it is 2\sqrt 2. Coordinates are then of the order of 1:

x^0=T0x0,x^1=T1x1,T=[s0−s uˉ0s−s vˉ001],s=2mean distance from (uˉ,vˉ)\hat x_0 = T_0 x_0, \quad \hat x_1 = T_1 x_1, \qquad T = \begin{bmatrix} s & 0 & -s\,\bar u \\ 0 & s & -s\,\bar v \\ 0 & 0 & 1 \end{bmatrix}, \quad s = \frac{\sqrt 2}{\text{mean distance from } (\bar u, \bar v)}

The 8-point algorithm on x^0,x^1\hat x_0, \hat x_1 gives F^\hat F. Since x^1⊤F^x^0=x1⊤T1⊤F^T0x0\hat x_1^\top \hat F \hat x_0 = x_1^\top T_1^\top \hat F T_0 x_0, the matrix for the pixel coordinates is F=T1⊤F^T0F = T_1^\top \hat F T_0.

Enforce rank 2

A true fundamental matrix is singular, it has rank 2, and all epipolar lines of an image meet in the epipole. The solution of Af=0Af = 0 does not know this, and with noise it comes out with full rank: its epipolar lines no longer pass through a common point. The repair takes the SVD of the estimate, sets the smallest singular value to zero and multiplies it back together:

F^=Udiag⁡(σ1,σ2,σ3)V⊤  →  Udiag⁡(σ1,σ2,0)V⊤\hat F = U \operatorname{diag}(\sigma_1, \sigma_2, \sigma_3) V^\top \;\rightarrow\; U \operatorname{diag}(\sigma_1, \sigma_2, 0) V^\top

This is the rank-2 matrix closest to the estimate in the Frobenius norm, the rank approximation of the SVD. It is applied to F^\hat F before the normalization is undone.

Algebraic and geometric error

The 8-point algorithm minimizes ∣Af∣|Af|, an algebraic quantity without a direct meaning in the image. The panel measures the error that matters: the distance in pixels of each x1x_1 from its epipolar line F^x0\hat F x_0, for the points used and for other points that played no part in the estimate. Like linear calibration, the 8-point algorithm is fast and needs no initial guess, and its result is usually refined by a non-linear method that minimizes a geometric error.

Try this