```html Understanding Camera Models in Detail โ€” Complete Guide

๐Ÿ“š Understanding Camera Models in Detail

Complete HTML version

๐Ÿ“– Table of Contents โ€” Understanding Camera Models in Detail

From foundations โ†’ classical models โ†’ full camera matrix โ†’ calibration โ†’ advanced topics.
  1. Part I: Foundations of Camera Models
  2. Part II: Classical Camera Models
  3. Part III: Mathematical Formulation of Camera Projection
  4. Part IV: Practical Considerations in Real Cameras
  5. Part V: Camera Calibration
  6. Part VI: Advanced Topics

๐Ÿ“ท Part I: Foundations of Camera Models

1. Introduction to Camera Models

๐Ÿ” Why Do We Need Camera Models?

In computer vision, the camera is the interface between the 3D world and a 2D digital image. A camera model is a mathematical abstraction that describes this transformation.

Mathematically, a 3D point

$$ X = (X, Y, Z, 1)^T $$

is projected to a 2D pixel

$$ x = (u, v, 1)^T $$

through a camera projection function:

$$ x \sim P X $$

where \(P \in \mathbb{R}^{3 \times 4}\) is the camera matrix.

Without a model, tasks like 3D reconstruction, augmented reality overlays, or robot navigation would be impossible โ€” because we couldnโ€™t reason how the 2D images relate back to the 3D world.

โš™๏ธ Applications in Vision and Robotics

  • Computer Vision: 3D reconstruction, depth estimation, object recognition.
  • Robotics: visual SLAM (Simultaneous Localization and Mapping), robot navigation.
  • AR/VR: overlaying graphics aligned with the physical world.
  • Industrial/Medical: photogrammetry, medical imaging, surgical navigation.

๐Ÿ•ฐ Historical Note: From Pinhole to Digital Cameras

  • Pinhole Camera (5th century BCE): used by Mozi (China) and Aristotle (Greece) โ€” a dark chamber with a tiny hole projects an inverted image.
  • Renaissance Perspective (15th century): Alberti and Brunelleschi formalized projection geometry for art.
  • 19thโ€“20th century: photographic film and glass lenses dominate.
  • Modern Era: CCD/CMOS sensors replace film, but the geometry (pinhole model + distortions) still forms the mathematical backbone.

2. Geometry of Image Formation

๐ŸŒž Light, Rays, and Projection

  • Each 3D point emits or reflects light rays in all directions.
  • The camera aperture (pinhole) restricts rays so that exactly one ray per 3D point reaches the image plane.
  • This ensures a unique mapping: one world point โ†’ one image point.

Mathematical Setup:
Let the camera coordinate system have origin at the optical center \(O\), with the \(Z\)-axis pointing forward. A world point in camera coordinates is

$$ X_c = (X_c, Y_c, Z_c)^T $$

The ray from \(O\) through \(X_c\) intersects the image plane at distance \(f\) (focal length) along the \(Z\)-axis.

By similar triangles (see diagram placeholder below):

$$ x_i = \frac{f X_c}{Z_c}, \quad y_i = \frac{f Y_c}{Z_c} $$

This is the perspective projection equation.

Figure placeholder โ€” 3D point, pinhole at origin, rays intersecting the image plane at distance \(f\).

๐ŸŽฏ The Concept of the Optical Center

  • The optical center (camera center) is the point where all rays converge.
  • In the pinhole model, itโ€™s a single idealized point; in real cameras, it approximates the entrance pupil center.

๐Ÿ–ผ The Image Plane vs. the Sensor Plane

  • In pure geometry, the image plane is placed behind the pinhole at distance \(f\) โ†’ inverted image.
  • Equivalently, a virtual image plane in front of the pinhole yields the same math up to a reflection.
  • In real cameras, the sensor plane (CCD/CMOS) is a discrete pixel array; mapping to pixels is handled by the intrinsic matrix \(K\).

3. Homogeneous Coordinates

โšก Why Do We Use Homogeneous Coordinates?

Perspective projection involves division by depth \((Z_c)\):

$$ x_i = \frac{f X_c}{Z_c}, \quad y_i = \frac{f Y_c}{Z_c} $$

This is nonlinear. But using homogeneous coordinates, we can write projection as a linear matrix multiplication.

โœ Representing Points

  • A 2D point \((u,v)\) is \((u,v,1)^T\).
  • A 3D point \((X,Y,Z)\) is \((X,Y,Z,1)^T\).
  • More generally: \( (x,y) \equiv (kx, ky, k) \ \forall k \neq 0 \) (defined up to scale).

๐Ÿ“ Representing Lines and Transformations

  • A 2D line \(ax + by + c = 0\) is the vector \((a,b,c)^T\).
  • Incidence: \(l^T x = 0\) โ‡” point \(x\) lies on line \(l\).
  • Geometric transforms (translation, rotation, projection) become matrices in homogeneous coordinates.
Example: 2D translation by (t_x, t_y)
T = [[1, 0, t_x],
     [0, 1, t_y],
     [0, 0,   1]]
x' = T x

๐ŸŒ Projective Geometry Basics

Homogeneous coordinates extend Euclidean geometry into projective geometry:

  • Points at infinity and vanishing points are naturally represented.
  • Camera projection matrix \(P\) is a \(3\times4\) projective transform, enabling the compact form \( \tilde{x} \sim P \tilde{X} \).

โ†‘ Back to Table of Contents

๐Ÿ“ท Part II: Classical Camera Models

4. The Pinhole Camera Model

๐Ÿ“Œ Basic Setup and Assumptions

  • Dark box, tiny aperture (pinhole), and an image plane.
  • Aperture is infinitesimal (ideal), no lens refraction, purely perspective geometry.
Figure placeholder โ€” rays from a 3D point passing through the pinhole to form an image.

๐Ÿ“ Perspective Projection Equations

Let the image plane be at distance \(f\).

$$ x_i = \frac{f X_c}{Z_c}, \quad y_i = \frac{f Y_c}{Z_c} $$

๐Ÿ”„ Image Inversion and Virtual Image Plane

  • Physical plane behind pinhole โ†’ inverted image.
  • Virtual plane in front โ†’ same math without inversion.

๐Ÿ” Aperture Size Trade-offs

Aperture SizeBrightnessSharpness
SmallDimSharp (few rays)
LargeBrightBlurred (many rays)

This trade-off motivates lenses: more light while preserving focus.


5. Lens-Based Models

๐Ÿ”Ž The Thin Lens Equation

Replacing the pinhole with a convex lens lets multiple rays converge to a point on the sensor.

$$ \frac{1}{f} = \frac{1}{z_o} + \frac{1}{z_i} $$

  • \(f\): focal length, \(z_o\): object distance, \(z_i\): image distance.
Figure placeholder โ€” thin lens focusing near vs. far objects.

๐ŸŽฏ Depth of Field and Focus

  • Only a specific distance is perfectly in focus; others blur to circles of confusion.
  • DoF increases with smaller aperture; affected by focal length and sensor size.

๐Ÿ“‰ Lens Distortions

  1. Radial distortion (barrel / pincushion):

    $$ x_d = x (1 + k_1 r^2 + k_2 r^4 + \dots),\quad y_d = y (1 + k_1 r^2 + k_2 r^4 + \dots) $$

  2. Tangential distortion (misalignment):

    $$ x_d = x + [2 p_1 xy + p_2 (r^2 + 2x^2)], \\ y_d = y + [p_1 (r^2 + 2y^2) + 2p_2 xy] $$

Figure placeholder โ€” grid showing barrel vs. pincushion distortion.

6. Alternative Simplified Models

๐Ÿชž Weak Perspective Model

Assume all scene points at approximately same depth \(z_0\):

$$ x' = \frac{f}{z_0} X, \quad y' = \frac{f}{z_0} Y $$

๐Ÿ“ Orthographic Projection

Parallel rays, camera at infinity:

$$ x' = X, \quad y' = Y $$

โš–๏ธ Scaled Orthographic (Paraperspective)

$$ x' = \frac{f}{Z_0} X, \quad y' = \frac{f}{Z_0} Y $$

๐Ÿค” When Approximations Are Useful

  • Orthographic: far objects, minimal depth variation.
  • Weak / Paraperspective: mild perspective effects, simpler math.
  • Full perspective: close objects or precision geometry.

โ†‘ Back to Table of Contents

๐Ÿ“ Part III: Mathematical Formulation of Camera Projection

7. Extrinsic Parameters (World โ†’ Camera)

๐Ÿ“ Camera Coordinate System

  • Origin at optical center, \(Z\)-axis forward, \(X\) right, \(Y\) down.

๐Ÿ”„ Rotation Matrix \(R\)

$$ X' = R X_W, \quad R \in SO(3), \ R^T R = I, \ \det(R)=+1 $$

โž• Translation Vector \(t\)

$$ X_C = R X_W + t $$

๐Ÿงฉ Rigid Body Transformation

$$ \begin{bmatrix} X_C \\ 1 \end{bmatrix} = \begin{bmatrix} R & t \\ 0 & 1 \end{bmatrix} \begin{bmatrix} X_W \\ 1 \end{bmatrix} $$


8. Intrinsic Parameters (Camera โ†’ Pixels)

๐ŸŽฏ Effective Focal Lengths \(f_x, f_y\)

$$ f_x = m_x f,\quad f_y = m_y f $$

๐Ÿ“ Principal Point \((c_x, c_y)\)

Intersection of optical axis with sensor; near image center but not exact.

๐Ÿ”€ Skew and Pixel Aspect Ratio

Skew \(s = f_x \cot\theta\) if axes not perfectly orthogonal.

๐Ÿ— Calibration Matrix \(K\)

$$ K = \begin{bmatrix} f_x & s & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \end{bmatrix} $$


9. The Full Camera Matrix

๐Ÿงฎ Derivation: \(P = K [R|t]\)

Start with homogeneous world point \(\tilde{X}_W = (X,Y,Z,1)^T\):

  1. \(\ X_C = [R|t]\tilde{X}_W\)
  2. \(\ x_{img} = (X_C/Z_C, \ Y_C/Z_C, \ 1)^T\)
  3. \(\ x = K x_{img}\)

$$ x \sim K [R|t] \tilde{X}_W \ \Rightarrow \ P = K [R|t] $$

๐Ÿ“Š Properties and Degrees of Freedom

  • \(K\): 5 DOF, \([R|t]\): 6 DOF โ†’ \(P\) has 11 DOF up to scale.

๐ŸŒ Geometric Interpretation

Each pixel corresponds to a ray \(X_W(\lambda)=C+\lambda d\); projection collapses depth, so itโ€™s non-invertible.


10. Projection in Homogeneous Coordinates

๐Ÿงพ Matrix Form of Projection

$$ \tilde{x} = \begin{bmatrix} u \\ v \\ w \end{bmatrix} \sim P \begin{bmatrix} X \\ Y \\ Z \\ 1 \end{bmatrix} $$

โœ‚๏ธ Perspective Divide

$$ (u', v') = \left(\frac{u}{w}, \frac{v}{w}\right) $$

๐Ÿ“ธ From 3D Points to 2D Pixels

  1. World โ†’ camera via \([R|t]\)
  2. Perspective divide \(/Z_c\)
  3. Intrinsics \(K\) โ†’ pixel \((u,v)\)

โ†‘ Back to Table of Contents

๐Ÿ“ท Part IV: Practical Considerations in Real Cameras

11. Lens Distortion Models

Ideal pinhole maps straight 3D lines to straight 2D lines; real lenses bend rays โ†’ distortion.

๐Ÿ”ต Radial Distortion

$$ r^2 = x^2 + y^2 $$

$$ x_d = x (1 + k_1 r^2 + k_2 r^4 + k_3 r^6), \quad y_d = y (1 + k_1 r^2 + k_2 r^4 + k_3 r^6) $$

๐Ÿ”ถ Tangential Distortion

$$ x_d = x + [2p_1 xy + p_2(r^2 + 2x^2)], \\ y_d = y + [p_1(r^2 + 2y^2) + 2p_2 xy] $$

๐Ÿ›  Modeling and Correction

Estimate \(K\) and distortion parameters together (e.g., OpenCV calibrateCamera); correction uses inverse mapping (often iterative).

Figure placeholder โ€” checkerboard before vs. after distortion correction.

12. Sensor Characteristics

๐ŸŸฆ Discretization into Pixels

$$ u = \lfloor m_x x_i + c_x \rfloor,\quad v = \lfloor m_y y_i + c_y \rfloor $$

Sampling causes aliasing on high-frequency patterns.

๐Ÿ”Š Noise and Quantization

  • Photon shot, thermal, and readout noise.
  • \(b\)-bit sensor โ†’ intensities in \([0, 2^b-1]\).

๐ŸŽฅ Rolling Shutter Effects

Rows exposed sequentially; fast motion bends geometry.

$$ t_i = t_0 + i \Delta t \ \Rightarrow \ x(t), y(t) \sim P(t) X_W $$


13. Multi-Camera Systems

๐Ÿ”€ Stereo Geometry and Epipolar Constraint

$$ x_R^T F x_L = 0 $$

If intrinsics known, essential matrix \(E = K_R^T F K_L\).

๐Ÿ— Structure from Motion (SfM)

$$ x_{ij} \sim P_i X_j $$

Estimate relative poses, triangulate, then bundle adjust.

๐ŸŒ Camera Networks and Panoramic Cameras

Arrays and panoramic systems require nonlinear projection models (e.g., fisheye).

โ†‘ Back to Table of Contents

๐Ÿ“ท Part V: Camera Calibration

14. Why Calibration Matters

Intrinsics

  • Focal lengths \((f_x, f_y)\)
  • Principal point \((c_x, c_y)\)
  • Skew, aspect ratio
  • Distortion parameters

Extrinsics

  • Rotation \(R\)
  • Translation \(t\)

๐Ÿ”Ž Applications

  • 3D measurement, pose estimation, reconstruction, robotics & navigation.

15. Linear Camera Calibration

15.1 Projection Equation

$$ x \sim P X,\ \ P \in \mathbb{R}^{3 \times 4} $$

In inhomogeneous form: \( u = \frac{p_1^T X}{p_3^T X}, \ v = \frac{p_2^T X}{p_3^T X} \)

15.2 Linear Constraints

$$ u (p_3^T X) - (p_1^T X) = 0,\quad v (p_3^T X) - (p_2^T X) = 0 $$

Stack into \(A\,\text{vec}(P)=0\) with \(A\in \mathbb{R}^{2n\times12}\).

15.3 Solving with SVD

Solve \(\min \|A p\|\) s.t. \(\|p\|=1\); take last singular vector, reshape to \(P\).

15.4 Requirements & Degenerate Cases

  • โ‰ฅ 6 correspondences (12 equations).
  • Points must not be coplanar (rank deficiency otherwise).

16. Nonlinear Optimization (Bundle Adjustment)

16.1 Reprojection Error

$$ \hat{x}(X) = \pi(K, R, t, d;\, X),\quad e = \|x - \hat{x}(X)\|^2 $$

Multi-view objective: $$ E = \sum_{i,j} \|x_{ij} - \pi(P_i, X_j)\|^2 $$

16.2 Optimization

  • Nonlinear least squares (e.g., Levenbergโ€“Marquardt).
  • Optimize \(K, R, t,\) and distortion \((k_1,k_2,p_1,p_2,\dots)\).

17. Practical Calibration Pipelines

17.1 Checkerboard Calibration

  1. Print checkerboard of known square size.
  2. Capture many views at varied orientations.
  3. Detect corners โ†’ build 2Dโ€“3D correspondences.
  4. DLT for initial \(P\) โ†’ nonlinear refinement.

17.2 OpenCV Implementation

  • findChessboardCorners(), calibrateCamera()
  • Returns \(K\), distortion coeffs, and per-image \((R_i,t_i)\).

17.3 Evaluating Calibration Accuracy

  1. Reprojection error: RMS < ~0.5 px (depends on resolution).
  2. Cross-validation: hold-out images.
  3. Stability: many images; cover full FOV.

โ†‘ Back to Table of Contents

๐Ÿ“ท Part VI: Advanced Topics in Camera Models

18. Special Camera Models

18.1 Fish-eye Cameras

Very wide FOV; rays mapped with nonlinear radial functions. Let \(\theta\) be the angle from optical axis:

  • Equidistant: \( r = f \theta \)
  • Equisolid: \( r = 2f \sin(\theta/2) \)
  • Stereographic: \( r = 2f \tan(\theta/2) \)
  • Orthographic: \( r = f \sin\theta \)

18.2 Catadioptric Cameras

Lenses + curved mirrors, often with single effective viewpoint. Unified sphere model:

$$ x = \frac{X}{Z+\xi \sqrt{X^2+Y^2+Z^2}},\quad y = \frac{Y}{Z+\xi \sqrt{X^2+Y^2+Z^2}} $$

18.3 Omnidirectional Cameras

Full 360ยฐ coverage; spherical mapping:

$$ u = \arctan2(Y,X),\quad v = \arccos\!\left(\frac{Z}{\sqrt{X^2+Y^2+Z^2}}\right) $$

Unwrap to equirectangular for panoramic images.


19. Camera Model Extensions

19.1 Projective Ambiguity & Self-Calibration

For any invertible \(4\times4\) \(H\): \(P' = P H,\ X' = H^{-1} X\) gives the same images \(x\sim PX = P'X'\).

Use the Image of the Absolute Conic \(\omega=K^{-\top}K^{-1}\) for self-calibration constraints.

19.2 Multi-View Geometry Basics

$$ x'^T F x = 0,\quad E = K'^T F K $$

Decompose \(E\) to get relative pose \((R,t)\).

19.3 Absolute vs. Relative Camera Pose

Relative: pose of cam 2 w.r.t cam 1. Absolute: pose in world frame via PnP with known 3Dโ€“2D matches.


20. Modern Applications of Camera Models

20.1 Augmented Reality & Pose Estimation

Align graphics by estimating pose \((R,t)\) s.t. \( \hat{x} = K [R|t] X\) aligns with features.

20.2 SLAM & Visual Odometry

Minimize $$ E = \sum_{i,j} \| x_{ij} - \pi(K, R_i, t_i, X_j)\|^2 $$ over poses and 3D structure.

20.3 Neural Rendering (NeRFs, Differentiable Cameras)

Each pixel casts a ray: $$ \mathbf{r}(t) = C + t \, R \, K^{-1}(u,v,1)^T $$ Volume rendering integrates along rays to produce color; differentiable projection is key for learning.

โœ… Wrap-Up: Special models (fisheye, catadioptric, omni) extend beyond pinhole; multi-view geometry couples cameras; calibration resolves metric scale; modern AR/SLAM/NeRFs critically rely on accurate camera models.

โ†‘ Back to Table of Contents

```