[CV] Example: Fundamental Matrix and Epipolar Line (등극선)

2024. 7. 16. 00:38·Programming/DIP
728x90
728x90

Fundamental Matrix와 Epipolar Line

Fundamental matrix $\mathbf{F}$ 는 두 카메라의 이미지 평면 (u-v coordinates) 상에서 correspondence 사이의 기하학적 관계를 나타내는 행렬임.

  • 두 카메라 간의 extrinsic parameters와 각 카메라의 intrinsic parameters에 의해 결정됨.
  • intrinsic parameters를 알고 있으면서 $\mathbf{F}$를 얻으면, extrinsic parameters $\mathbf{R}$과 $\mathbf{t}$를 구할 수 있음.
  • Essential Matrix의 generalization이라고도 볼 수 있음.

Finding Correspondences = 1D searching

Stereo vision에서 Dense Depth Map을 구하기 위해선
한 image의 모든 pixel에 대해 다른 image에서의 corresponding point를 찾아야 함: Finding Dense Correspondence

  • 이 때 사용되는 searching은 2D search가 아닌 대응하는 epipolar line에 대한 1D search가 됨.
  • 즉, 특정 point (u,v)에 대해 epipolar line을 구하고, 해당 line에서 가장 matching이 잘되는 지점을 corresponding point로 삼는 것임.
  • 그리고 얻어진 이 두 점을 통해, triangulation을 통해 disparity를 계산하여 depth를 구하게 됨.
  • 이를 모든 pixel에 대해 수행하여 dense depth map을 구하게 된다. 

2024.06.28 - [Programming/DIP] - [CV] Epipolar Geometry [작성중]

 

[CV] Epipolar Geometry [작성중]

epipolar geometry는두 개의 카메라 images에서대응하는 점들 사이의 기하학적 관계를 설명하는 데 사용되는 용어Epipolar geometry는 각 카메라 image 상의 각 점이 epipolar line을 통해 어떻게 연결되었는지를

dsaint31.tistory.com


Fundamental Matrix를 통한 Epipolar Line 계산

주어진 점 $\mathbf{p}_1 = [x_1, y_1, 1]^\top$이 첫 번째 카메라 이미지 상에 있을 때, 이 점에 대응하는 두 번째 카메라 이미지 상의 에피폴라 라인은 다음과 같이 계산됨:

$$
\mathbf{l}_2 = \mathbf{F} \mathbf{p}_1
$$

여기서

  • $\mathbf{l}_2$는 Epipolar Line을 나타내는 3x1 벡터임.
  • 이 벡터는 두 번째 카메라의 이미지 평면 상에서 eq. of epipolarine $a x + b y + c = 0$의 coefficients $[a, b, c]^\top$ 를 나타냄.

2024.06.16 - [.../Math] - [Math] Homogeneous Coordinate and Projective Geometry

 

[Math] Homogeneous Coordinate and Projective Geometry

Homogeneous Coordinates (동차 좌표)와 Projective Geometry (사영 기하학)1. 개요1-1. Homogeneous Coordinates의 정의와 특성Homogeneous Coordinates (동차 좌표)는 Euclidean Coordinates (유클리드 좌표) 시스템을 확장하여 Proje

dsaint31.tistory.com


예제

두 카메라의 Fundamental matrix $\mathbf{F}$가 다음과 같이 주어졌다고 가정함:

$$
\mathbf{F} = \begin{bmatrix}
0 & -0.02 & 0.3 \\
0.02 & 0 & -0.4 \\
-0.3 & 0.4 & 1
\end{bmatrix}
$$

첫 번째 카메라 이미지에서의 점 $\mathbf{p}_1$이 다음과 같이 주어졌다고 가정함:

$$
\mathbf{p}_1 = \begin{bmatrix}
0.5 \
0.6 \
1
\end{bmatrix}
$$

이제 이 점에 대응하는 두 번째 카메라의 이미지 상의 Epipolar Line을 다음과 같이 계산함.


계산

$$
\mathbf{l}_2 = \mathbf{F} \mathbf{p}_1
$$

이를 계산하면:

$$
\mathbf{l}_2 = \begin{bmatrix}
0 & -0.02 & 0.3 \\
0.02 & 0 & -0.4 \\
-0.3 & 0.4 & 1
\end{bmatrix}
\begin{bmatrix}
0.5 \
0.6 \
1
\end{bmatrix}
= \begin{bmatrix}
-0.02 \cdot 0.6 + 0.3 \cdot 1 \\
0.02 \cdot 0.5 - 0.4 \cdot 1 \\
-0.3 \cdot 0.5 + 0.4 \cdot 0.6 + 1
\end{bmatrix}
= \begin{bmatrix}
0.288 \\
-0.39 \\
0.16
\end{bmatrix}
$$

따라서, 두 번째 이미지 카메라의 이미지 평면에서의 Epipolar Line 의 방정식은 다음과 같음:

$$
0.288 x - 0.39 y + 0.16 = 0
$$


결과 해석

위의 결과는 첫 번째 카메라 이미지 평면에서의 점 $\mathbf{p}_1 = [0.5, 0.6, 1]^\top$ 이 두 번째 카메라 이미지 평면에서 대응하는 Epipolar Line의 방정식이 $0.288 x - 0.39 y + 0.16 = 0$ 임을 의미함.


Python을 이용한 계산

다음은 Python을 사용하여 동일한 계산을 수행하고 에피폴라 라인을 시각화하는 코드임:

import numpy as np
import matplotlib.pyplot as plt

# Fundamental matrix
F = np.array([[0, -0.02, 0.3],
              [0.02, 0, -0.4],
              [-0.3, 0.4, 1]])

# Point in the first image
p1 = np.array([0.5, 0.6, 1])

# Calculate the epipolar line in the second image
l2 = np.dot(F, p1)

# Define the range of x values for plotting
x = np.linspace(0, 1, 100)
# Calculate the corresponding y values
y = -(l2[0] * x + l2[2]) / l2[1]

# Plot the epipolar line
plt.plot(x, y, '-r', label='Epipolar line')
plt.xlabel('x')
plt.ylabel('y')
plt.title('Epipolar Line in the Second Image')
plt.legend()
plt.grid()
plt.show()

같이 보면 좋은 자료들

https://youtu.be/erpiFudDBlg?si=t-I6brYe_9e_Kj6A

 

'Programming > DIP' 카테고리의 다른 글

[CV] Stereo Calibration or Stereo Camera Calibration  (0) 2024.07.16
[CV] Example: Essential Matrix and Epipolar Line  (2) 2024.07.16
[CV] Pose: Position + Orientation  (0) 2024.07.09
[CV] Intrinsic Rotation and Extrinsic Rotation  (0) 2024.07.07
[Math] Euler Angles and Rotation Matrix  (0) 2024.07.07
'Programming/DIP' 카테고리의 다른 글
  • [CV] Stereo Calibration or Stereo Camera Calibration
  • [CV] Example: Essential Matrix and Epipolar Line
  • [CV] Pose: Position + Orientation
  • [CV] Intrinsic Rotation and Extrinsic Rotation
dsaint31x
dsaint31x
    반응형
    250x250
  • dsaint31x
    Dsaint31's blog
    dsaint31x
  • 전체
    오늘
    어제
    • 분류 전체보기 (740)
      • Private Life (13)
      • Programming (186)
        • DIP (104)
        • ML (26)
      • Computer (119)
        • CE (53)
        • ETC (33)
        • CUDA (3)
        • Blog, Markdown, Latex (4)
        • Linux (9)
      • ... (351)
        • Signals and Systems (103)
        • Math (172)
        • Linear Algebra (33)
        • Physics (42)
        • 인성세미나 (1)
      • 정리필요. (54)
        • 의료기기의 이해 (6)
        • PET, MRI and so on. (1)
        • PET Study 2009 (1)
        • 방사선 장해방호 (4)
        • 방사선 생물학 (3)
        • 방사선 계측 (9)
        • 기타 방사능관련 (3)
        • 고시 (9)
        • 정리 (18)
      • RI (0)
      • 원자력,방사능 관련법 (2)
  • 블로그 메뉴

    • Math
    • Programming
    • SS
    • DIP
  • 링크

    • Convex Optimization For All
  • 공지사항

    • Test
    • PET Study 2009
    • 기타 방사능관련.
  • 인기 글

  • 태그

    numpy
    Convolution
    math
    SIGNAL
    signal_and_system
    function
    linear algebra
    fourier transform
    Python
    Term
    Optimization
    인허가제도
    opencv
    Probability
    Programming
    SS
    Vector
    검사
    random
    signals_and_systems
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
dsaint31x
[CV] Example: Fundamental Matrix and Epipolar Line (등극선)
상단으로

티스토리툴바