[CV] 8-point algorithm: Fundamental Matrix

2024. 7. 17. 08:28·Programming/DIP
728x90
728x90

1. SIFT 등을 이용하여 reliable corresponding features 를 8쌍 이상 추출.

 


2. 1번 과정에서 찾은 correspondance에 Epipolar Constraint를 적용하여 matrix equation을 얻음.

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

 

[CV] Epipolar Geometry [작성중]

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

dsaint31.tistory.com

 

예를 들어 $i$-th correspondance $(\mathbf{p}_R^{(i)}, \mathbf{p}_L^{(i)})$에 다음이 성립.

$${\mathbf{p}_L^{(i)}}^\top \mathbf{F} {\mathbf{p}_R^{(i)}}= 0$$

 

이를 풀어서 쓰면 다음과 같음.

$$\begin{bmatrix} u_L^{(i)} & v_L^{(i)} & 1 \end{bmatrix} \begin{bmatrix} f_{11} & f_{12} & f_{13} \\ f_{21} & f_{22} & f_{23} \\ f_{31} & f_{32} & f_{33}=1 \end{bmatrix} \begin{bmatrix} u_R^{(i)} \\ v_R^{(i)} \\ 1 \end{bmatrix} = 0$$

 

위 matrix equation은 다음의 linear equation과 같음.

$$(f_{11}u_R^{(i)}+f_{12}v_r^{(i)}+f_{13})u_L^{(i)} +(f_{21}u_R^{(i)}+f_{22}v_R^{(i)}+f_{23})v_L^{(i)}+(f_{31}u_R^{(i)}+f_{32}v_R^{(i)}+f_{33})=0$$

 

8개의 coorespondance를 모두 사용하면 다음을 얻음.

$$\begin{bmatrix} u_R^{(1)}u_L^{(1)} & v_R^{(1)}u_L^{(1)} & u_L^{(1)} & u_R^{(1)}v_L^{(1)} & v_R^{(1)}v_L^{(1)} & v_L^{(1)} & u_R^{(1)} & v_R^{(1)} & 1 \\ \vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots \\ u_R^{(8)}u_L^{(8)} & v_R^{(8)}u_L^{(8)} & u_L^{(8)} & u_R^{(8)}v_L^{(8)}& v_R^{(8)}v_L^{(8)} & v_L^{(8)} & u_R^{(8)} & v_R^{(8)} & 1 \end{bmatrix} \begin{bmatrix} f_{11} \\ f_{12} \\f_{13}\\f_{21}\\f_{22}\\f_{23}\\f_{31}\\f_{32}\\f_{33}=1 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \end{bmatrix}$$

 

이를 다음과 같이 기재할 수 있음.

$$\mathbf{A} \mathbf{f} = \mathbf{0}$$

 

여기서 $\mathbf{A}$는 8쌍의 correspondance로 부터 구할 수 있고, zero vector $\mathbf{0}$는 상수이므로, unknown이 8개인 $\mathbf{f}$를 충분히 구할 수 있음.


3. Fundamental Matrix는 scale ambiguity 를 통해 $\|\mathbf{f}\|^2=1$이라는 constraint를 주어 하나의 $\mathbf{F}$를 얻도록 함.

$${ \mathbf{p}_L^{(i)} }^\top \mathbf{F} \mathbf{p}_R^{(i)} = 0 ={\mathbf{p}_L^{(i)} }^\top k \mathbf{F} \mathbf{p}_R^{(i)}$$

 

$\mathbf{F}$와 $k\mathbf{F}$는 같은 epipolar geometry에 해당하므로, scale을 고정하여 하나의 $\mathbf{F}$를 구해야함.

때문에 $\|\mathbf{f}\|^2=1$을 앞서 구한 equation의 constraint로 추가함.


4. 이는 다음의 constrained least squares problem이 유도됨.

$\|\mathbf{f}\|^2=1$이라는 제한 조건 하에서 이상적으로 $\mathbf{A}\mathbf{f}=0$이 만족하는 $\mathbf{f}$를 구해야 하나,

측정의 noise 등으로 인해 최대한 0에 가까워지도록 해주는 $\mathbf{f}$를 구하면 됨.

 

이는 다음과 같은 constrained minization problem이 된다.

 

$$\underset{\mathbf{f}} {\text{argmin }} \|\mathbf{Af}\|^2 \text{ s.t. } \|f\|^2=1$$

 

이는 constrained least squares 등의 Direct Linear Transform을 푸는 방법으로 쉽게  $\mathbf{f}$를 구할 수 있음을 뜻함.

2024.07.16 - [분류 전체보기] - [ML] Constrained Least Squares: Lagrangian 을 활용.

 

[ML] Constrained Least Squares: Lagrangian 을 활용.

문제설정흔히 볼 수 있는 least squares problem은 다음과 같음.$$\mathbf{A'f'}=\mathbf{b}$$ 이를 다음과 같이 augmented matrix와 homogeneous coordinate를 사용하여 homogeneous equation형태로 정리할 수 있음.$$ \mathbf{A} =

dsaint31.tistory.com

 

실제로는 u-v pixel coordinates를 그대로 사용하지 않고,

Hartley's normalization을 수행하여 normalizaed constrained least squares 를 함.

(이 경우 수치적인 안정성이 보다 높음)

2024.07.17 - [Programming/DIP] - [CV] Hartley’s Normalization

 

[CV] Hartley’s Normalization

Hartley’s NormalizationHartley's normalization은 Stereo Calibration의 Fundamental Matrix를 구하는데 주로 사용되는 normalization으로 기하학적 좌표들을 다룰 때 수치적 안정성을 확보하기 위해 애용됨. Hartley의 nor

dsaint31.tistory.com

 

least square로 구해진 $\hat{\mathbf{f}}$를 rearrange하여 구한 $\hat{\mathbf{F}}$는 singular matrix가 아닐 수 있음(noise 등으로 인해).

때문에 $\text{det } F$ 가 되도록 rank-2 approximation을 수행하기도 함.

 

마지막으로 least squares를 수행하기 전의 normalization을 되돌리기 위한 denoramlization을 수행하여 $\mathbf{F}$를 구함.


5. 각 카메라의 intrinsic parameters $\mathbf{K}_L$와 $\mathbf{K}_R$ 를 통해 Essential Matrix $\mathbf{E}$를 구함.

$$\mathbf{E}=\mathbf{K}_L^\top \mathbf{F} \mathbf{K}_R$$

2024.06.22 - [Programming/DIP] - [CV] Geometric Camera Model

 

[CV] Geometric Camera Model

Geometric Camera Model (or Camera Model)은 real world 와  camera의 pose에 따라,real world 와  camera의 image 간의 관계를approximation 함. 이 문서에서는 기본적인 Pinhole Camera Model에 기반하여 설명함.Pinhole Camera Model

dsaint31.tistory.com

 


6. $\mathbf{E}$로부터 SVD를 통해, $\mathbf{R}$과 $\mathbf{t}$를 구한다.

$$ \mathbf{E} = [\mathbf{t}]_\times \mathbf{R}$$

 

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

 

[CV] Epipolar Geometry [작성중]

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

dsaint31.tistory.com

 


같이 보면 좋은 자료들

https://velog.io/@cjkangme/CS231A-%EA%B0%95%EC%9D%98-%EB%85%B8%ED%8A%B8-3-epipolar-geometry-2

 

CS231A 강의 노트 3 - epipolar geometry (2)

이전 게시글 4. Fundamental Matrix Essential Matrix를 구할 때에는 두 카메라가 canonical camera라고 가정하였다. 그러나 현실의 카메라에 적용하기 위해서는 canonical이 아닌 카메라에 대응하는 Matrix가 필요

velog.io

 

728x90

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

[CV] Depth Cameras  (1) 2024.07.17
[CV] Hartley’s Normalization  (1) 2024.07.17
[CV] Stereo Calibration or Stereo Camera Calibration  (0) 2024.07.16
[CV] Example: Essential Matrix and Epipolar Line  (2) 2024.07.16
[CV] Example: Fundamental Matrix and Epipolar Line (등극선)  (1) 2024.07.16
'Programming/DIP' 카테고리의 다른 글
  • [CV] Depth Cameras
  • [CV] Hartley’s Normalization
  • [CV] Stereo Calibration or Stereo Camera Calibration
  • [CV] Example: Essential Matrix and Epipolar Line
dsaint31x
dsaint31x
    반응형
    250x250
  • dsaint31x
    Dsaint31's blog
    dsaint31x
  • 전체
    오늘
    어제
    • 분류 전체보기 (787)
      • Private Life (15)
      • Programming (206)
        • DIP (116)
        • ML (35)
      • Computer (120)
        • CE (54)
        • ETC (33)
        • CUDA (3)
        • Blog, Markdown, Latex (4)
        • Linux (9)
      • ... (368)
        • Signals and Systems (115)
        • Math (176)
        • Linear Algebra (33)
        • Physics (43)
        • 인성세미나 (1)
      • 정리필요. (61)
        • 의료기기의 이해 (6)
        • PET, MRI and so on. (7)
        • PET Study 2009 (1)
        • 방사선 장해방호 (5)
        • 방사선 생물학 (3)
        • 방사선 계측 (9)
        • 기타 방사능관련 (3)
        • 고시 (9)
        • 정리 (18)
      • RI (0)
      • 원자력,방사능 관련법 (2)
  • 블로그 메뉴

    • Math
    • Programming
    • SS
    • DIP
  • 링크

    • Convex Optimization For All
  • 공지사항

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

  • 태그

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

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
dsaint31x
[CV] 8-point algorithm: Fundamental Matrix
상단으로

티스토리툴바