v9.1.1
Menu

Epipolar Line Visualization

hardPROEpipolar GeometryCVCV: Depth Estimation

Implement a function to compute and draw epipolar lines given a fundamental matrix. The fundamental matrix is a key concept in Epipolar Geometry, which describes the relationship between two images of the same scene taken from different viewpoints. This relationship is crucial in Depth Estimation tasks, as it allows us to infer the 3D structure of the scene from 2D images.

To find the epipolar line in image 2 corresponding to a point in image 1, we can use the following process:

  1. Represent the point in image 1 as a vector xx.
  2. Multiply the fundamental matrix FF by the point xx to obtain the coefficients of the epipolar line ll in image 2.
l=F⋅xl = F \cdot x

This technique is widely used in computer vision applications, such as stereo vision and structure from motion.

Function

Implement epipolar_line(F, point), where F is the 3×33 \times 3 fundamental matrix and point holds the pixel coordinates (x,y)(x, y) of a point in image 1 (it may also be given in homogeneous form (x,y,1)(x, y, 1)). Treat the point as the homogeneous vector (x,y,1)(x, y, 1) and return the line coefficients (a,b,c)(a, b, c) of ax+by+c=0ax + by + c = 0 in image 2 as a 1D numpy array of shape (3,)(3,).

Example

Input
Point and F matrix
Output
Epipolar line coefficients
Reasoning
  • Inputs: F is the 3×33 \times 3 fundamental matrix linking image 1 to image 2, and point is a pixel (x,y)(x, y) in image 1. Using the test's values: F=(000001010)F = \begin{pmatrix}0&0&0\\0&0&1\\0&1&0\end{pmatrix} and the point (320,240)(320, 240).
  • Homogeneous form: the pixel becomes x=(320,240,1)Tx = (320, 240, 1)^T. The appended 1 lets a 3×33 \times 3 matrix act on a 2D point.
  • Math: each coefficient of l=Fxl = F x is one row of FF dotted with xx: a=0a = 0, b=0⋅320+0⋅240+1⋅1=1b = 0 \cdot 320 + 0 \cdot 240 + 1 \cdot 1 = 1, c=0⋅320+1⋅240+0⋅1=240c = 0 \cdot 320 + 1 \cdot 240 + 0 \cdot 1 = 240.
  • Output: the epipolar line coefficients (a,b,c)=(0,1,240)(a, b, c) = (0, 1, 240), shape (3,)(3,), i.e. the line v+240=0v + 240 = 0 in image 2. The matching point in image 2 must lie on it.
  • Notice: this FF has an all-zero first row, so every point gives a=0a = 0 and a horizontal line. Any nonzero multiple of ll is the same line, so the coefficients only matter up to scale.

Constraints

  • Input parameters: point (1D numpy array of shape (3,) with dtype float64), F (2D numpy array of shape (3, 3) with dtype float64)
  • Valid ranges: point coordinates in [0, 1000], F matrix elements in [-1000, 1000]
  • Output format: return epipolar line coefficients as 1D numpy array of shape (3,) with dtype float64, representing ax + by + c = 0
  • Special conditions: assume point is in homogeneous coordinates (x, y, 1) and F is a valid fundamental matrix with rank 2

Learn this in

More from CV: Depth Estimation

PRO

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test results

Sign in to run your code against the test cases.