Structure from Motion - Epipolar geometry

윤준영·2025년 3월 5일

Computer Vision

목록 보기
9/13

1. Definition

3차원 scene과 이 scene을 보고 있는 두 개의 카메라가 있을 때, 우리는 3D 좌표와 각 카메라의 이미지 평면에 투영된 2D 좌표를 이용하여 두 카메라 사이의 기하학적 관계를 설명할 수 있다. 이 두 카메라 사이의 기하학적 관계를 찾는 것을 epipolar geometry라고 한다.

위 그림에서 표시된 변수들은 다음과 같다.

  • C,C\bold{C}, \bold{C^{'}} : 카메라 중점

  • e,e\bold{e}, \bold{e}^{'} : Epipoles

  • xe,xe\overline{\bold{x}\bold{e}}, \overline{\bold{x}^{'}\bold{e}^{'}} : Epipolar lines

  • XCC\triangle \bold{X}\bold{C}\bold{C}^{'} : Epipolar plane

Epipolar geometry를 통해 두 카메라 및 두 이미지 사이의 변환관계를 구할 수 있다면, 두 개의 카메라에서 각 이미지 위의 좌표를 향해 ray를 쏴서 3D reconstruction을 진행할 수 있으므로 3D vision을 공부한다면 꼭 한 번 짚고 넘어가야 하는 개념이다.

2. Fundamental matrix

Fundamental matrix는 C,C,X\bold{C}, \bold{C}^{'}, \bold{X} 가 있을 때, 대응점 쌍 (x,x)(\bold{x}, \bold{x}^{'})에 대해 유일하게 결정되는 3×33 \times 3 행렬이다.

xTFx=0\bold{x^{'}}^{T}F\bold{x}=0

이 행렬을 안다면, 두 이미지 사이의 대응점 쌍을 찾을 수 있다. 즉, 한 점 x\bold{x}FF가 주어지면 x\bold{x}^{'}을 추론하는게 가능해진다.

2.1. 8-point algorithm

위 식을 다음과 같이 변형할 수 있다.

xTFx=0\bold{x^{'}}^TF\bold{x}=0
[xnyn1][F11F12F13F21F22F23F31F32F33][xnyn1]=0\begin{bmatrix}x^{'}_n & y^{'}_n & 1\end{bmatrix} \begin{bmatrix}F_{11} & F_{12} & F_{13} \\ F_{21} & F_{22} & F_{23} \\ F_{31} & F_{32} & F_{33}\end{bmatrix} \begin{bmatrix}x_n \\ y_n \\ 1\end{bmatrix} = 0
(F11xn+F12yn+F13)xn+(F21xn+F22yn+F23)yn+F31xn+F32yn+F33=0(F_{11}x_n + F_{12}y_n + F_{13})x_n^{'} + (F_{21}x_n + F_{22}y_n + F_{23})y_n^{'} + F_{31}x_n+ F_{32}y_n + F_{33} = 0
[xnxnxnynxnxnynynynynxnyn1][F11F12F13F21F22F23F31F32F33]=0\begin{bmatrix}x_nx_n^{'} & x_n^{'}y_n & x_n^{'} & x_ny_n^{'} & y_ny_n^{'} & y_n^{'} & x_n & y_n & 1\end{bmatrix} \begin{bmatrix}F_{11} \\ F_{12} \\ F_{13} \\ F_{21} \\ F_{22} \\ F_{23} \\ F_{31} \\ F_{32} \\ F_{33}\end{bmatrix} = 0

Fundamental matrix는 scale이 정해져있지 않다. 즉, FF나 임의의 상수 kk가 곱해진 kFkF나 같은 결과를 뱉는다.

xTFx=xT(kF)x=0\bold{x^{'}}^{T}F\bold{x} = \bold{x^{'}}^{T}(kF)\bold{x} = 0

그래서 총 9개의 값 중 scale인 F33F_{33}을 제외한 8개의 파라미터만 추정하면 되므로, 8개의 feature point가 주워진다면 fundamental matrix를 구할 수 있다.

[x1x1x1y1x1x1y1y1y1y1x1y11x8x8x8y8x8x8y8y8y8y8x8y81][F11F12F13F21F22F23F31F32F33]=0AF=0\begin{bmatrix}x_1x_1^{'} & x_1^{'}y_1 & x_1^{'} & x_1y_1^{'} & y_1y_1^{'} & y_1^{'} & x_1 & y_1 & 1 \\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\ x_8x_8^{'} & x_8^{'}y_8 & x_8^{'} & x_8y_8^{'} & y_8y_8^{'} & y_8^{'} & x_8 & y_8 & 1\end{bmatrix} \begin{bmatrix}F_{11} \\ F_{12} \\ F_{13} \\ F_{21} \\ F_{22} \\ F_{23} \\ F_{31} \\ F_{32} \\ F_{33}\end{bmatrix} = 0 \\ AF = 0

행렬 AA는 언제나 full rank일 것이다. AA에 Singular Value Decomposition (SVD) 를 적용하여 UDVTUDV^T로 분리할 수 있는데, 여기서 VTV^T의 마지막 열을 다시 3×33 \times 3 으로 reshape 해준다면 우리가 구하는 fundamental matrix FF가 된다.

3. Essential matrix

Fundamental matrix는 uncalibrated인 상황에서 사용된다면, essential matrix는 calibrated인 상황에서 사용되므로 카메라의 파라미터를 알고있다고 가정한다.
Fundamental matrix를 구하기 위해 사용되는 x\bold{x}는 world coordinate에서 정의된 X\bold{X}에서 camera coordinate으로 변환하는 extrinsic parameters R,tR, \bold{t}, camera coordinate에서 pixel coordinate으로 변환하는 intrinsic parameters KK 를 이용하여 구해진다.

x=K[Rt]X\bold{x} = K[R|\bold{t}]\bold{X}

Essential matrix는 camera coordinate에서의 대응점 x,x\overline{\bold{x}}, \overline{\bold{x}^{'}}이 주어졌을 때의 fundamental matrix가 된다. K[Rt]K[R|\bold{t}]PP라 하면

x=K1PX\overline{\bold{x}}=K^{-1}P\bold{X}
xTEx=0\overline{\bold{x^{'}}}^{T}E\overline{\bold{x}}=0

캘리브레이션이 되어있으므로 우리는 KK를 알고 있고, fundamental matrix와 essential matrix는 E=KTFKE=K^{'^T}FK라는 관계를 가지고 있어서 쉽게 계산할 수 있다.

4. Pose estimation

Essential matrix EE를 분해하여 두 카메라 좌표계 사이의 변환관계를 설명하는 R,tR, \bold{t}를 구할 수 있다.
우선 EE는 SVD를 통해 분해할 수 있다. 여기서 essential matrix의 특성으로 인해 두 개의 singular value는 같고, 하나는 0이 된다.

E=U[100010000]VT(up to scale)E = U\begin{bmatrix}1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 0\end{bmatrix}V^T \quad (up \ to \ scale)

여기서 [010100001]\begin{bmatrix}0 & 1 & 0 \\ -1 & 0 & 0 \\ 0 & 0 & 1\end{bmatrix}로 구성된 행렬 WW를 이용하여

R1=UWVTR2=UWTVTt=U[001]orU[001]R_1 = UWV^T \\ R_2 = UW^TV^T \\ \bold{t} = U\begin{bmatrix}0 \\ 0 \\ 1\end{bmatrix} or -U\begin{bmatrix}0 \\ 0 \\ 1\end{bmatrix}

이렇게 최종 R,tR, \bold{t} 후보를 구하게 된다. 이들 중 복원되는 3D 좌표가 가장 많은 R,tR, \bold{t}가 최종 R,tR, \bold{t}가 된다.

profile
AMC AI research engineer

1개의 댓글

comment-user-thumbnail
2025년 4월 8일

이해가 잘됩니다

답글 달기