[CV] Geometric Camera Model and Camera Calibration: Pinhole Camera

2024. 6. 22. 14:20·Programming/DIP
728x90
728x90

Geometric Camera Model (or Camera Model)은 

  • real world 의 scene 과  camera의 pose (= orientation + location) 에 따라,
  • real world 의 scene 과  camera의 image 간의 기하학적 관계(geometrical relation)를
  • approximation 함.

참고: 2D image를 3D scene의 perpective prjection 이라는 가정에 기반.

  • 이 경우 geometric relation 과 photometric relation을 알아야 image를 생성할 수 있음.
  • 이 문서는 geometric relation을 설명하는 Geometric Camera Model을 기술함.

이 문서에서는 기본적인 Pinhole Camera Model에 기반하여 설명함.

  • pinhole camera는 매우 기본적인 image acquisition의 수단임.
  • 초점이 잘 맺어진 선명한 상을 얻기 위한 가장 쉬운 방법이지만,
  • light이 작은 구멍(pinhole)을 통해 들어오기 때문에 매우 긴 촬영시간 (~노출시간, exposure time)이 필요함.
  • 때문에 현재의 카메라는 모두 lens기반임.

2024.08.09 - [Programming/DIP] - [CV] Ideal Pinhole Size

 

[CV] Ideal Pinhole Size

Pinhole Camera는 가장 기본적인 Camera Model로 Perspective Projection을 통해 image가 얻어진다. 보통 pinhole은 아주 작은 diameter의 구멍이지만, 사용하는 빛의 파장과 effective focal length에 따라 최적의 image를

dsaint31.tistory.com

 


1. Pinhole Camera Model

핀홀 카메라에서는 빛이 직선으로 이동하기 때문에, 외부의 물체는 이미지 평면에 거꾸로 된 상을 형성하게 됨.

  • Pinhole (핀홀): 작은 구멍을 통해 외부의 빛이 들어와서 이미지 평면에 상을 맺음.
  • Virtual Image Plane (가상 이미지 평면): 실제 이미지 평면의 반대편에 위치하며, 가상 이미지를 형성하는 평면.
    • 뒤집혀 있는 (real) image plane 대신 사용되며 같은 좌표계들을 적용함. 
  • (Real) Image Plane (이미지 평면):
    • 빛이 핀홀을 통해 들어와서 실제 이미지를 형성하는 평면: 뒤집혀지기 때문에 virtual image plane이 보다 많이 사용됨.
    • x-y 좌표계: image coordinate
      • 카메라의 image sensor 표면의 좌표계로 image coordinate라고도 불림.
      • 센서의 셀 크기 등을 반영하여 $mm$ 또는 $\mu m$ 등의 물리적 단위로 표현됨.
    • u-v 좌표계: pixel coordinate
      • image의 pixel 단위를 사용하는 좌표계.
      • sensor coordinate 가 적용되며, left top을 origin으로 삼음.
      • 카메라의 intrinsic parameters로 구성된 intrinsic matrix $K$를 comera coordinate에 적용하여 얻어냄.

2024.07.06 - [Programming/DIP] - [CV] Image Plane to Image Sensor Mapping

 

[CV] Image Plane to Image Sensor Mapping

Image Plane에서의 coordinate $x_i, y_i$는mm단위를 가지며결과 image의 coordinate라고 생각할 수 있다.하지만 계산의 용이성 때문에 $x_i, y_i$ 보다는normalized image plane의 coordinate $x_n, y_n$ 이 많이 사용된다.현

dsaint31.tistory.com

 

2024.06.29 - [Programming/DIP] - [CV] Coordinate Systems

 

[CV] Coordinate Systems

이 글은 Computer Vision에서의 Coordinate Systems 을 다룬다.종류 및 정의World Coordinate (월드 좌표계):$\begin{bmatrix}x_w& y_w & z_w & 1\end{bmatrix}^T$카메라 외부에 존재하는 객체(object)의 위치를 전역적인 좌표계

dsaint31.tistory.com

 

다음은 lens를 사용하는 경우에 대한 모식도임.

더보기

 참고: Thin Lens Camera Model


2. Parameters: Intrinsic and Extrinsic

Real world의 좌표계와  Camera의 좌표계, 그리고 이미지의 좌표계간의

관계를  Camera Model은  approximation 하며,

다음의 파라메터로 구성됨.


2-1. Intrinsic Parameters (Camera가 내재적으로 가지는 parameters)

  • Principal Point, $\color{red}{\begin{bmatrix}u_o,v_o\end{bmatrix}^\top}$ : optical center
  • Focal Length : $\color{red}{f_x,f_y}$ : unit aspect ratio $f_x=f_y$
    • $f_x = m_x f, f_y = m_y f$ : $m_x, m_y$ are pixel densities (pixels/mm)
  • Skew Coefficient (최근의 digital camera에서 0임), $\color{red}{s}$ : no skew $s=0$
  • camera intrinsic matrix $K$로 표현된다.

Extrinsic Parameters는

  • World coordinate 를 Camear Coordinate로 바꾸고

Intrinsic Parameters는

  • depth $z_c$가 1이 되도록 normalization 시킨 normalized image plane의 좌표 $\begin{bmatrix}x_n & y_n & 1\end{bmatrix}^\top$를
  • 실제 image 상의 좌표 $\begin{bmatrix}u & v & 1\end{bmatrix}^\top$로 바꾸어주는 역할을 한다.

$$\begin{bmatrix}u \\ v \\ 1\end{bmatrix} = K \begin{bmatrix} x_n \\y_n \\1 \end{bmatrix} = \begin{bmatrix} f_x & s & u_o \\ 0 & f_y & v_o \\ 0 & 0 & 1 \end{bmatrix}\begin{bmatrix} x_n \\y_n \\1 \end{bmatrix}$$

 

오늘날 카메라는 대부분 unit aspect ratio라 $f_x = f_y=f$이고, skew 가 없다($s=0$).

때문에 다음의 관계가 성립함

$$ x_n = \frac{u-u_o}{f} = \frac{x_c}{z_c} \\ y_n = \frac{v-v_o}{f} = \frac{y_c}{z_c} $$

 

Camera Calibration에서 $K$는 normalized image plane의 $\begin{bmatrix} x_n & y_n & 1 \end{bmatrix}^\top$를 구하기 위해 $K^{-1}$로 사용된다.

즉, normalized image plane의 좌표는 camera calibration이 적용된 결과임.


2-2. Extrinsic Parameters (Real world에서 Camera의 pose에 의해 결정되는 parameters) 

  • Camera Position, $\color{blue}{\textbf{t}}$
  • Camera Orientation, $\mathbf{R}$ : camera rotation matrix (Orthogonal Matrix임)
더보기

2022.11.17 - [.../Math] - [LA] Orthogonal matrix (직교행렬)

 

[LA] Orthogonal Matrix (직교행렬) and Orthonormal Vector

Orthogonal MatrixMatrix의 row vector (and column vector)들이자기자신을 제외한 나머지 row vector (and column vector)들과 orthonormal인 square matrix.$$A^{-1}=A^\top \\ A^\top A = I \\ \mathbf{a}_i^\top \mathbf{a}_j = \mathbf{a}_i \cdot \mat

dsaint31.tistory.com


Projection from 3D world coordinates to 2D image coordinates

$$w\begin{bmatrix}u \\ v \\ 1 \end{bmatrix} = \color{red}{\mathbf{K}} \begin{bmatrix} \mathbf{R} & \color{blue}{\textbf{t}} \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix} = \color{red}{\begin{bmatrix} f_x & s & u_o \\ 0 & f_y & v_o \\ 0 & 0 & 1 \end{bmatrix}} \begin{bmatrix} r_{11} & r_{12} & r_{13} & \color{blue}{t_x} \\ r_{21} & r_{22} & r_{23} & \color{blue}{t_y} \\ r_{31} & r_{32} & r_{33} & \color{blue}{t_z}\end{bmatrix} \begin{bmatrix} x \\ y \\ z\\ 1 \end{bmatrix} $$

 

World Coordinate를 Camera Coordinate로 변경해주는 것이 Extrinsic Parameters로 구성된 Extrinsic Matrix $\begin{bmatrix}R & t\end{bmatrix}$가 하는 역할.


3. DoF

위의 camera model의 parameter는 결국 11개임 (Degree of Freedom=11) 

  • $\color{red}{\mathbf{K}}$ : DoF=5
  • $\mathbf{R}=\mathbf{R}_z\mathbf{R}_y\mathbf{R}_x=\begin{bmatrix} \cos \theta_z & - \sin\theta_z & 0 \\ \sin\theta_z & \cos \theta_z & 0 \\ 0 & 0 & 1 \end{bmatrix}\begin{bmatrix} \cos \theta_y & 0 & -\sin\theta_y \\ 0 & 1 & 0 \\ \sin\theta_y & 0 & \cos\theta_y \end{bmatrix}\begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos \theta_x & -\sin \theta_x \\ 0 & \sin \theta_x & \cos \theta_x \end{bmatrix}=\begin{bmatrix} \mathbf{x-axis}_w^\top \\ \mathbf{y-axis}_w^\top \\ \mathbf{z-axis}_w^\top\end{bmatrix}$ : DoF=3
    • $\mathbf{x-axis}_w, \mathbf{y-axis}_w, \mathbf{z-axis}_w$은
      • camera coordinate system (=camera frame)의 각 축의 방향을 나타내는
      • unit vector $\hat{\mathbf{x}}_c, \hat{\mathbf{y}}_c, \hat{\mathbf{z}}_c$를 
      • world coordinate system 으로 나타낸 것임.
    • 즉, "world frame"에서 카메라 좌표계의 각 축의 방향을 나타내는 unit vector임.
  • $\color{blue}{\textbf{t}}$ : DoF=3

Camear Calibration 과정에서 위에서 언급한 Camera model의 parameters를 구해진다.

위에서 살펴봤듯이 DoF=11 이므로 Camera Calibration을 하기 위해선, 6개의 correspondances 가 최소로 필요함.

  • 1개의 correspondance마다 2개의 식이 정의됨.

4. 같이 읽어보면 좋은 자료

2024.06.23 - [Programming/DIP] - [CV] Camera Model Parameter Estimation: $\underset{\textbf{x}}{\text{argmin }} \mathbf{x}^T A^T A \mathbf{x}$

 

[CV] Camera Model Parameter Estimation: $\underset{\textbf{x}}{\text{argmin }} \mathbf{x}^\top A^\top A \mathbf{x}$

Camera Model Parameter Estimation: $\underset{\textbf{x}}{\text{argmin }} \mathbf{x}^\top A^\top A \mathbf{x}$Camera Model Parameter Estimation 문제를$$\underset{\mathbf{x}}{\text{argmin }} \mathbf{x}^\top A^\top A \mathbf{x} \\ \text{subject to } \ ||\

dsaint31.tistory.com

 

오일석 교수님의 책: 컴퓨터 비전과 딥러닝 (2022) 12장

https://books.google.co.kr/books/about/%EC%BB%B4%ED%93%A8%ED%84%B0_%EB%B9%84%EC%A0%84%EA%B3%BC_%EB%94%A5%EB%9F%AC%EB%8B%9D.html?id=o9-lEAAAQBAJ&redir_esc=y

 

https://jordicenzano.name/front-test/2d-3d-paradigm-overview-2011/camera-model/

 

Camera model

Introduction In this section I explain all necessary steps to obtain a mathematical camera model. Pinhole Camera – Image formation If we put a film directly in front of the object that we wan…

jordicenzano.name

https://kr.mathworks.com/help/vision/ug/camera-calibration.html

 

카메라 보정이란? - MATLAB & Simulink - MathWorks 한국

다음 MATLAB 명령에 해당하는 링크를 클릭했습니다. 명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.

kr.mathworks.com


 

728x90

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

[CV] Two View Geometry  (0) 2024.06.28
[CV] Camera Model Parameter Estimation: $\underset{\textbf{x}}{\text{argmin }} \mathbf{x}^\top A^\top A \mathbf{x}$  (0) 2024.06.23
[Fitting] Hough Transform  (0) 2024.06.13
[CV] Fitting  (0) 2024.06.13
[DIP] Image Stitching  (0) 2024.06.13
'Programming/DIP' 카테고리의 다른 글
  • [CV] Two View Geometry
  • [CV] Camera Model Parameter Estimation: $\underset{\textbf{x}}{\text{argmin }} \mathbf{x}^\top A^\top A \mathbf{x}$
  • [Fitting] Hough Transform
  • [CV] Fitting
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
    • 기타 방사능관련.
  • 인기 글

  • 태그

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

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
dsaint31x
[CV] Geometric Camera Model and Camera Calibration: Pinhole Camera
상단으로

티스토리툴바