[ORB SLAM 2] Solve PnP(한동대 황성수 교수님 강좌)

아킬라·2023년 8월 2일
0

개념 공부

목록 보기
2/6
post-thumbnail

Represent Camera motion

1. Translation

  • 카메라가 3차원 공간에서 이동한 경우, 이동량을 translation이라고 함
  • 3차원 점 (x,y,z)에서 (x',y',z')으로 이동한 경우 translation은 vector t=(x'-x, y'-y, z'-z)로 표현 가능

2. Rotation

  • 카메라가 x,y,z 축에서 회전한 경우, 이 회전 값을 rotation이라고 한다.

Pose estimation이란?

  • 물제가 고정되어 있는 경우, 3차원 공간 상에서 카메라의 translation과 rotation을 구하는 과정
  • 물체가 고정된 경우 카메라의 포즈를 추정하고 카메라가 고정된 경우 물체의 포즈를 추정

Pose estimation을 위해 필요한 요소

1. 2D coordinates of a few points

  • 2차원 이미지 상의 점 (x,y)

2. 3D locations of the same points

  • 2차원 이미지에 대응하는 3차원 상의 점 (x,y,z)
  • World coordiate: 3차원 상에서 특정한 점을 절대 원점으로 삼아 물체의 좌표를 표현한 좌표계
  • Camera coordiate: 3차원 상에서 카메라의 중심을 원점으로 물체의 좌표를 표현한 좌표계

3. Intrinsic parameters of the camera

  • Focal length of camera, optimal center in the image, radial distortion(방사 왜곡) parameters를 원소로 하는 행렬
  • Camera coordinates의 좌표에 intrinsic parameter를 곱하면 Image coordinates의 좌표를 구할 수 있음

4. How to do pose estimation?

  • 카메라의 pose(rotation, translation)을 알고 있다고 가정할 때, world coordinate의 점 P(U, V, W)를 다음 수식을 통해 camera coordiate의 점(X, Y, Z)로 투영할 수 있다.

    World coordiate의 점에 rotion과 translation으로 이루어진 행렬을 곱하면 camera coordiate의 점이 나오는데 이렇게 world coordinate를 camera coordiate로 바꿔주는 행렬을 extrinsic parameter라고 함


  • 2차원 평면 상의 점 p(x,y)는 camera intrinsic parameter, 즉 다음 수식을 통해 구할 수 있다.

Camera coordiate의 점에 focal length와 optical center로 이루어진 intrinsic parameter 행렬을 곱하면 Image coordiates의 점가 나오게 된다.
IImage coordinates란 이미지 평면 위로 투영한 좌표계를 의미함

  • 앞의 수식 2개를 합칩으로써, 다음과 같이 점(X, Y, Z)의 위치를 구할 수 있다.


-> 우리는 위의 식을 이용하여 2D point(x,y), 3D point(U, V, W), camera intrinsic parameter를 알 때 역으로 rotation과 translation을 예측 가능!

2D point에 intrinsic parameter의 역행렬을 곱하면 Camera coordiate(X, Y, Z)를 구할 수 있음
Camera coordinates 좌표와 3D point(U, V, W)를 알면 rotation과 translation 정보로 구성된 행렬인 extrinsic parameter를 예측 가능하다. 즉, rotation과 translation을 알 수 았게 됨

OpenCV Solve PnP

  • Solve PnP란 위와 같이 2D point(x,y), 3D point(U, V, W), camera intrinsic parameter를 통해 tranlation과 rotation을 추정하는 것을 의미

  • Camera의 intrinsic parameter를 알고 있는 경우, camera pose 추정을 가능하게 하는 OpenCV 함수

  • SolvePnP() input

  1. objectPoints: world coordinate상의 3차원 점들
  2. imagePoints: 3차원 점들에 대응하는 image 상의 2차원 점들
  3. cameraMatrix: camera intrinsic parameter
  4. distCoeffs: camera distortion coefficients

SolvePnP() output
1. rotation vector(Rodrigues 형태로 표현)
2. translation vector

Rodrigues란?

  • 일반적으로 rotation은 3X3 matrix로 표현됨
  • 이 3X3 matrix를 Rodrigues's rotation formula를 사용하여
    4개의 값(회전축 벡터 + 회전각)만으로 표현할 수 있다.

ORB SLAM에서의 SolvePnP?

  • ORB SLAM을 이루는 시스템 중 하나인 Tracking에서 initial pose estimation 단계에서 카메라 위치 추정을 위해 사용됨!
  • 영상에서 추출한 ORB feature를 기반으로 카메라 위치 추정

Reference

https://www.youtube.com/watch?v=tDfAbqQQO0o&list=PLoJdZ7VvEiRNUxlIXlgy7Fh8ziyt4Hw50&index=3

profile
자율 주행 개발자가 목표입니다.

0개의 댓글

관련 채용 정보