PIXELBANKv9.1.0
Menu

Fundamental Matrix Estimation (8-Point Algorithm)

The Fundamental Matrix FF defines the geometric relationship between corresponding points in two images from uncalibrated cameras. For corresponding points x1x_1 and x2x_2, they must satisfy the epipolar constraint:

x2T⋅F⋅x1=0x_2^T \cdot F \cdot x_1 = 0

Your task is to implement the 8-Point Algorithm to estimate FF from point correspondences:

  1. Build matrix AA: For each point pair, create a row: [x2x1,x2y1,x2,y2x1,y2y1,y2,x1,y1,1][x_2 x_1, x_2 y_1, x_2, y_2 x_1, y_2 y_1, y_2, x_1, y_1, 1]

  2. Solve Af=0Af = 0: Use SVD to find the vector ff that minimizes ∥Af∥2\|Af\|^2 subject to ∥f∥=1\|f\|=1. This is the last column of VV (or last row of VTV^T).

  3. Reshape: Convert the 9-element vector ff into a 3×33 \times 3 matrix FF.

  4. Normalize: Divide FF by its Frobenius norm ∥F∥F\|F\|_F.

Return FF as a 3×33 \times 3 matrix with elements rounded to 4 decimal places.

Example:

Input:
x1_pairs = [[10, 50, 1], [20, 60, 1], [30, 70, 1], [40, 80, 1],
           [50, 90, 1], [60, 100, 1], [70, 110, 1], [80, 120, 1]]
x2_pairs = [[15, 55, 1], [25, 65, 1], [35, 75, 1], [45, 85, 1],
           [55, 95, 1], [65, 105, 1], [75, 115, 1], [85, 125, 1]]
Output:
[[-0.0005, 0.0034, -0.2376], [-0.0046, 0.0018, -0.0783], [0.2271, -0.003, 0.9412]]
Reasoning:
  1. Build 8×98 \times 9 matrix AA from point pairs
  2. Compute SVD: A=UΣVTA = U \Sigma V^T
  3. ff = last row of VTV^T (corresponds to smallest singular value)
  4. Reshape ff to 3×33 \times 3 matrix FF
  5. Normalize: F=F/∥F∥FF = F / \|F\|_F

Constraints:

  • At least 8 corresponding point pairs required
  • Input points are in homogeneous coordinates [x,y,1][x, y, 1]
  • Output FF should be normalized (Frobenius norm = 1)
  • Round output elements to 4 decimal places
solution.py

Test Results

0/0
Run code to see test results.