v9.1.1
Menu

Essential Matrix Estimation

hardFREERANSAC for AlignmentGeometryCV: Image Alignment and Stitching

Implement a method to estimate the essential matrix between two camera views using the 8-point algorithm. This task is crucial in image alignment and stitching as it relates corresponding points in two views through the equation p2TEp1=0\mathbf{p}_2^T E \mathbf{p}_1 = 0. The essential matrix EE encodes the rotation and translation between views, up to scale, and is a fundamental concept in computer vision.

To estimate EE, the process involves several steps:

  1. Normalizing points to improve numerical stability
  2. Building a constraint matrix AA from correspondences
  3. Solving Af=0Af = 0 via Singular Value Decomposition (SVD)
  4. Enforcing the essential-matrix constraint on EE: rank 2 with two equal non-zero singular values, i.e. Σ=diag(s,s,0)\Sigma = \text{diag}(s, s, 0). Rank 2 alone only gives a fundamental matrix.
E=[e11e12e13e21e22e23e31e32e33]E = \begin{bmatrix} e_{11} & e_{12} & e_{13} \\ e_{21} & e_{22} & e_{23} \\ e_{31} & e_{32} & e_{33} \end{bmatrix}

This technique is widely used in structure from motion and stereo vision applications.

Example

Input
pts1 = [8 or more corresponding points]
pts2 = [corresponding points in second view]
Output
3×3 essential matrix
Reasoning
  • Inputs: pts1 and pts2 hold N≥8N \ge 8 matches in normalized camera coordinates (row ii of each is one 3D point seen from both views), each treated as p=(x,y,1)\mathbf{p} = (x, y, 1). In the 12-match test the first pair is (0.065785,−0.110576)(0.065785, -0.110576) and (0.452675,−0.089485)(0.452675, -0.089485).
  • One equation per match: expanding p2TEp1=0\mathbf{p}_2^T E \mathbf{p}_1 = 0 is linear in the nine entries eije_{ij}, with coefficients x2x1≈0.0298x_2x_1 \approx 0.0298, x2y1≈−0.0501x_2y_1 \approx -0.0501, x2≈0.4527x_2 \approx 0.4527, …, 11. Twelve matches give 12 equations in 9 unknowns. Since scale is free, you want the unit-norm EE that brings all twelve closest to zero.
  • Structure: that best fit is generally not a valid essential matrix; it is replaced by the nearest matrix with singular values (s,s,0)(s, s, 0).
  • Output: E≈[0.5371.638−3.500−4.2670.54917.0013.161−17.4841]E \approx \begin{bmatrix} 0.537 & 1.638 & -3.500 \\ -4.267 & 0.549 & 17.001 \\ 3.161 & -17.484 & 1 \end{bmatrix} Its singular values are 17.881,17.881,017.881, 17.881, 0, and every match gives p2TEp1≈−0.0001\mathbf{p}_2^T E \mathbf{p}_1 \approx -0.0001, effectively zero next to entries of size 17.
  • Notice: any nonzero multiple of EE is equally correct, so the tests check structure (rank 2, two equal singular values, near-zero residual), not exact entries.

Constraints

  • pts1, pts2: Corresponding normalized points (N, 2)
  • Return: Essential matrix E (3×3): rank 2 with two equal non-zero singular values

Learn this in

More from CV: Image Alignment and Stitching

solution.py

Test results

Sign in to run your code against the test cases.