Computer Vision MT25, Camera models


Flashcards

@Define the single-view ambiguity.

The observation that one image is not enough to determine the true location of objects in the image (even given perfect knowledge about the camera itself)).

@exam~

@Define the camera coordinate system.

The coordinate system where:

  • The optical centre is at the origin (i.e. the location of the pinhole in the pinhole camera model, or the effective centre of projection more generally)
  • The $z$ axis is the optical axis, perpendicular to the image plane
  • The $xy$ plane is parallel to the image plane, $x$ is horizontal and $y$ is vertical

@Visualise (or draw) the relationship between a 3D point $P = (x, y, z)$ and it’s projection $P'$ onto the image plane given a focal length $f$ in the pinhole camera model and in the camera coordinate system, and @state the projection and location of the 2D point on the image plane.

Setup (the ∆camera-coordinate-system): the camera is the optical centre $O$ (the pinhole), placed at the origin. The optical axis is the $z$-axis, and the image plane is perpendicular to it at distance $f$ (the focal length). A scene point $P = (x, y, z)$ sits at depth $z$; its image $P'$ is where the ray $P \to O$ meets the image plane.

Projection: the diagram is the side ($z$-$y$) view. Triangle $OP$ (legs $z$ and $y$) is similar to triangle $OP'$ (legs $f$ and $y'$), so $y' / f = y / z$, and likewise for $x$. Hence

\[P' = \left( f \frac{x}{z}, \; f \frac{y}{z} \right)\]

The depth $z$ in the denominator is what makes distant objects appear smaller.

Matrix form: in homogeneous coordinates the whole projection is one matrix multiply, with the perspective division by $z$ applied last:

\[\begin{bmatrix} f & 0 & 0 & 0 \\ 0 & f & 0 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix} = \begin{pmatrix} fx \\ fy \\ z \end{pmatrix} \;\cong\; \left( f \frac{x}{z}, \; f \frac{y}{z} \right)\]

@exam~

In what way is orthographic projection a special case of perspective projection?

It is where the distance from the centre of the projection to the image plane is infinite.

What matrix corresponds to orthographic projection in (homogenous) camera coordinates?

\[\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix} = \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}\]

@exam~

@Define the normalised coordinate system.

  • The camera centre is at the origin
  • The principal axis is the $z$-axis
  • $x$ and $y$ axes of the image plane are parallel to axes of the world

@Define the camera calibration problem and give its typical factorisation into intrinsic and extrinsic camera parameters.

Camera calibration is the problem of determining the transformation from the world coordinate system to the image coordinate system.

\[\begin{pmatrix} \text{2D}\\ \text{point}\\ \boldsymbol{x}\\ (3\times 1) \end{pmatrix} \;\cong\; \begin{pmatrix} \text{Camera to}\\ \text{pixel coord.}\\ \text{trans. matrix}\\ \boldsymbol{K}\ (3\times 3) \end{pmatrix} \begin{pmatrix} \textit{Canonical}\\ \text{projection matrix}\\ [I\mid 0]\ (3\times 4) \end{pmatrix} \begin{pmatrix} \text{World to}\\ \text{camera coord.}\\ \text{trans. matrix}\\ \begin{pmatrix} R & t\\]

3pt] 0^{\mathsf T} & 1 \end{pmatrix}\ (4\times 4) \end{pmatrix} \begin{pmatrix} \text{3D}\ \text{point}\ \boldsymbol{X}\ (4\times 1) \end{pmatrix}

\[where: - $\mathbf K$ encodes the intrinsic camera parameters: focal length, principal point, and pixel-scaling factors - $\begin{pmatrix}\mathbf R & t \\ \pmb 0^\top & 1\end{pmatrix}$ encodes the extrinsic parameters: rotation and translation of the camera relative to the world - $[I \mid 0]$ is the canonical projection matrix that drops the homogeneous coordinate when going from the world-frame 4D to camera-frame 3D. All together we have the general camera projection matrix $\mathbf P$ so that \]

\pmb x \quad\cong\quad \mathbf K[\mathbf R \mid \pmb t] \pmb X \quad\cong\quad \mathbf P \mathbf X

$$

@Define the principal point $\pmb p$. Where is it in the normalised coordinate system and the image coordinate system?

  • $\pmb p$: The point where the principal axis (i.e. the one perpendicular to the image plane coming from the world) intersects the image plane
  • In the normalised coordinate system: the centre of the image
  • In the image coordinate system: the corner of the image

In the camera calibration problem, we wish to determine the transformation from the world coordinate system to the image coordinate system.

\[\begin{pmatrix} \text{2D}\\ \text{point}\\ \boldsymbol{x}\\ (3\times 1) \end{pmatrix} \;\cong\; \begin{pmatrix} \text{Camera to}\\ \text{pixel coord.}\\ \text{trans. matrix}\\ \boldsymbol{K}\ (3\times 3) \end{pmatrix} \begin{pmatrix} \textit{Canonical}\\ \text{projection matrix}\\ [I\mid 0]\ (3\times 4) \end{pmatrix} \begin{pmatrix} \text{World to}\\ \text{camera coord.}\\ \text{trans. matrix}\\ \begin{pmatrix} \mathbf R & \pmb t\\]

3pt] \pmb 0^{\top} & 1 \end{pmatrix}\ (4\times 4) \end{pmatrix} \begin{pmatrix} \text{3D}\ \text{point}\ \boldsymbol{X}\ (4\times 1) \end{pmatrix}

\[where: - The first matrix represents the intrinsic camera parameters: principal point and scaling factors - The second matrix represents the extrinsic camera parameters: $\mathbf R$otation, $\mathbf t$ranslation of the camera All together we have the general camera projection matrix $\mathbf P$ so that \]

\begin{aligned} \pmb x &\cong \mathbf K[\mathbf R \mid \pmb t] \pmb X \ &\cong \mathbf P \mathbf X \end{aligned}

$$

Can you write out all the entries of $\mathbf P$, and explain what each does?

\[\begin{aligned} \mathbf P &= \mathbf K[\mathbf R \mid \pmb t] \\ &= \left( \begin{bmatrix} m _ x & 0 & 0 \\ 0 & m _ y & 0 \\ 0 & 0 & 1 \\ \end{bmatrix} \begin{bmatrix} f & 0 & p _ x \\ 0 & f & p _ y \\ 0 & 0 & 1 \\ \end{bmatrix} \right) \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} \, \begin{bmatrix} \mathbf R & \pmb t\\]

3pt] \pmb 0^{\top} & 1 \end{bmatrix} \end{aligned}

$$

where:

  • $\mathbf R$ and $\mathbf t$ is a rotation that maps from the world coordinates to the normalised camera coordinates
  • $f$ is the focal length
  • $p _ x, p _ y$ is the location of the principal point in image coordinates
  • $m _ x, m _ y$ are the number of pixels per $m$ in the horizontal and vertical directions

In the camera calibration problem, we wish to determine the transformation from the world coordinate system to the image coordinate system.

\[\begin{pmatrix} \text{2D}\\ \text{point}\\ \boldsymbol{x}\\ (3\times 1) \end{pmatrix} \;\cong\; \begin{pmatrix} \text{Camera to}\\ \text{pixel coord.}\\ \text{trans. matrix}\\ \boldsymbol{K}\ (3\times 3) \end{pmatrix} \begin{pmatrix} \textit{Canonical}\\ \text{projection matrix}\\ [I\mid 0]\ (3\times 4) \end{pmatrix} \begin{pmatrix} \text{World to}\\ \text{camera coord.}\\ \text{trans. matrix}\\ \begin{pmatrix} \mathbf R & \pmb t\\]

3pt] \pmb 0^{\top} & 1 \end{pmatrix}\ (4\times 4) \end{pmatrix} \begin{pmatrix} \text{3D}\ \text{point}\ \boldsymbol{X}\ (4\times 1) \end{pmatrix}

\[where: - The first matrix represents the intrinsic camera parameters: principal point and scaling factors - The second matrix represents the extrinsic camera parameters: $\mathbf R$otation, $\mathbf t$ranslation of the camera All together we have the general camera projection matrix $\mathbf P$ so that \]

\begin{aligned} \pmb x &\cong \mathbf K[\mathbf R \mid \pmb t] \pmb X \ &\cong \mathbf P \mathbf X \end{aligned}

$$

Derive the “linear method” for determining $\mathbf P$?

Forget all the parameters in $\mathbf P$ and instead consider it as

\[\mathbf P = \begin{bmatrix} p _ {11} & p _ {12} & p _ {13} & p _ {14} \\ p _ {21} & p _ {22} & p _ {23} & p _ {24} \\ p _ {31} & p _ {32} & p _ {33} & p _ {34} \end{bmatrix}\]

Given $n$ points with known 3D coordinates $\mathbf X _ i$ and image projections $\pmb x _ i$, we have

\[\pmb x _ i \cong \mathbf P \pmb X _ i\]

Writing

\[\mathbf P _ j = \begin{bmatrix} p _ {j1} \\ p _ {j2} \\ p _ {j3} \\ p _ {j4} \end{bmatrix}\]

therefore

\[\begin{bmatrix} x _ i \\ y _ i \\ 1 \end{bmatrix} \cong \begin{bmatrix} \pmb X _ i^\top \mathbf P _ 1 \\ \pmb X _ i^\top \mathbf P _ 2 \\ \pmb X _ i^\top \mathbf P _ 3 \end{bmatrix}\]

or equivalently

\[\begin{aligned} \mathbf X _ i^\top P _ 1 - x _ i \mathbf X _ i^\top \mathbf P _ 3 &= 0 \\ \mathbf X _ i^\top P _ 2 - y _ i \mathbf X _ i^\top \mathbf P _ 3 &= 0 \end{aligned}\]

Collecting this into a matrix equation, we obtain

\[\begin{bmatrix} \mathbf X _ i^\top & 0 & -x _ i \mathbf X _ i^\top \\ 0 & \mathbf X _ i^\top & -y _ i \mathbf X _ i^\top \end{bmatrix} \begin{bmatrix} \mathbf P _ 1 \\ \mathbf P _ 2 \\ \mathbf P _ 3 \end{bmatrix}\]

Repeating this for the $n$ points, we obtain

\[\mathbf A \pmb p = 0\]

where

\[\begin{aligned} \mathbf A &= \begin{bmatrix} \mathbf X _ 1^\top & 0 & -x _ 1 \mathbf X _ 1^\top \\ 0 & \mathbf X _ 1^\top & -y _ 1 \mathbf X _ 1^\top \\ & \vdots & \\ \mathbf X _ n^\top & 0 & -x _ n \mathbf X _ n^\top \\ 0 & \mathbf X _ n^\top & -y _ n \mathbf X _ n^\top \\ \end{bmatrix} \\ \\ \pmb p &= \begin{bmatrix} \mathbf P _ 1 \\ \mathbf P _ 2 \\ \mathbf P _ 3 \end{bmatrix} \end{aligned}\]

which can be solved via least squares.

@prove~

What is the downside of linear calibration?

Linear calibration recovers $\mathbf P$ has 11 free parameters, but not in the factored form $\mathbf P = \mathbf K[\mathbf R \mid t]$, so you can’t directly obtain the explicit intrinsic and extrinsic parameters.

How does nonlinear calibration differ from linear calibration?

You instead formulate the problem of determining the parameters via a loss function and solve via nonlinear optimisation methods.

@State the defining properties of a 3D rotation matrix, give the matrices for rotation about each coordinate axis, and state the degrees of freedom.

A 3D rotation is any matrix $R \in \mathbb R^{3 \times 3}$ satisfying $R^\top R = I _ 3$ (orthogonal) and $\det R = +1$ (orientation-preserving). These are the defining properties of $\mathrm{SO}(3)$.

Rotations about the coordinate axes (right-hand rule, counter-clockwise viewed from the positive end of the axis):

\[R _ x(\theta) = \begin{pmatrix} 1 & 0 & 0 \\ 0 & \cos\theta & -\sin\theta \\ 0 & \sin\theta & \cos\theta \end{pmatrix}, \quad R _ y(\theta) = \begin{pmatrix} \cos\theta & 0 & \sin\theta \\ 0 & 1 & 0 \\ -\sin\theta & 0 & \cos\theta \end{pmatrix}, \quad R _ z(\theta) = \begin{pmatrix} \cos\theta & -\sin\theta & 0 \\ \sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{pmatrix}.\]

Mnemonic: the $1$ sits in the row and column of the rotation axis, and the other $2 \times 2$ block is the standard 2D rotation matrix (∆bite-2d-rotation-matrix), with the sign convention flipped for $R _ y$ to keep the right-hand rule.

Degrees of freedom: 3. The upper bound comes from counting: 9 entries minus 6 orthonormality constraints (three for unit-length columns, three for pairwise orthogonality). The matching lower bound comes from the Euler-angle parametrisation: any rotation factors as $R = R _ z(\alpha) R _ y(\beta) R _ x(\gamma)$, a smooth surjection $\mathbb R^3 \to \mathrm{SO}(3)$, so $\dim \ge 3$.

Useful corollary: $R^{-1} = R^\top$, so inverting a rotation is free.

Source: standard NLA / geometry fact; appears throughout MVG and camera models as part of the camera extrinsics $[R \mid \pmb t]$.

@State what $R$ and $\pmb t$ physically represent in the extrinsic matrix $[R \mid \pmb t]$, and explain why $\pmb t$ is not the position of the camera in the world.

The extrinsic matrix $[R \mid \pmb t]$ is the rigid transformation that converts world coordinates into camera coordinates:

\[\pmb X _ \text{cam} = R \pmb X _ \text{world} + \pmb t.\]
  • $R \in \mathrm{SO}(3)$ is the rotation that aligns the world axes with the camera axes. Equivalently, its rows are the world-frame coordinates of the camera’s $x, y, z$ basis vectors.
  • $\pmb t \in \mathbb R^3$ is the position of the world origin expressed in camera coordinates. It is where the world origin appears from the camera’s point of view.

Common confusion: $\pmb t$ is not the camera position in the world. The camera position in world coordinates, $\pmb C$, is the world point that gets mapped to the camera’s own origin: $\pmb 0 = R\pmb C + \pmb t$, giving

\[\pmb C = -R^\top \pmb t.\]

So the camera-in-world is $\pmb C$, but the world-in-camera is $\pmb t$, and the two are related by the rotation $R^\top$ and a sign flip. Treating $\pmb t$ as the camera position will reliably break reconstructions.

Why $[R \mid \pmb t]$ is the natural form for the extrinsics: the camera projection $\pmb x \cong K[R \mid \pmb t]\pmb X$ first sends a world point through the rigid transformation $\pmb X \mapsto R\pmb X + \pmb t$ to put it in camera coordinates, then applies $K$ to project it into pixels. The decomposition is “where the point is from my perspective, then how my sensor digitises it”, which is the natural pipeline of the camera.

Source: Lec 14, Extrinsic Parameters slides; corollary of the calibration decomposition (∆camera-calibration-decomposition).

@State how to recover the camera centre $\tilde{\pmb C}$ from the projection matrix $P$, and justify the formula in both algebraic and geometric terms.

The camera centre $\tilde{\pmb C} \in \mathbb R^4$ in homogeneous world coordinates is the right null vector of $P$:

\[P \tilde{\pmb C} = \pmb 0.\]

Geometric reason: a generic 3D point $\pmb X$ projects to a 2D image point via the ray from $\pmb X$ through the camera centre $\pmb C$, and the projection picks out where this ray meets the image plane. For $\pmb X = \pmb C$ the ray collapses to zero length, so the projection is undefined. Algebraically, “undefined projection” corresponds to $P\tilde{\pmb C} = \pmb 0$, the zero vector in homogeneous coordinates, which represents no valid projective point. So the camera centre is the unique point in the right null space of $P$.

Algebraic verification from the factored form: with $P = K[R \mid \pmb t]$, set $\tilde{\pmb C} = \binom{\pmb C}{1}$ where $\pmb C = -R^\top \pmb t$. Then

\[P \tilde{\pmb C} = K[R \mid \pmb t] \binom{-R^\top \pmb t}{1} = K\big(R(-R^\top \pmb t) + \pmb t\big) = K(-\pmb t + \pmb t) = \pmb 0,\]

so $\pmb C = -R^\top \pmb t$ in inhomogeneous world coordinates.

Computational note: in the linear-calibration setting where $P$ is recovered as a flat $3 \times 4$ matrix without explicit $K, R, \pmb t$, you get $\tilde{\pmb C}$ from the SVD of $P$ as the right singular vector corresponding to its zero (smallest) singular value, then dehomogenise.

Source: standard fact in MVG; corollary of the calibration decomposition (∆camera-calibration-decomposition).

Bite-sized

The camera projection matrix $\mathbf P = \mathbf K[\mathbf R \mid \pmb t]$ has 11 degrees of freedom (the $3 \times 4$ matrix has 12 entries but is only defined up to scale).

Source: Lecture 14, Camera Calibration: Full Linear System slide.

@bite~

Each 2D-3D correspondence gives 2 linearly independent equations in the entries of $\mathbf P$, so the minimum number of correspondences needed for a linear solution to camera calibration is 6 (giving 12 equations for the 11 free parameters).

Source: Lecture 14, Camera Calibration: Full Linear System slide.

@bite~

The homogeneous least-squares problem $\mathbf A \pmb p = \pmb 0$ from linear camera calibration is solved by taking $\pmb p$ to be the eigenvector of $\mathbf A^\top \mathbf A$ corresponding to the smallest eigenvalue — equivalently the right singular vector of $\mathbf A$ associated with its smallest singular value.

Source: Lecture 14, Camera Calibration: Full Linear System slide.

@bite~ @exam~

The non-linear refinement of camera calibration minimises the reprojection error

\[\sum _ i \big\ \vert \mathrm{proj}(\mathbf K [\mathbf R \mid \pmb t] \mathbf X _ i) - \pmb x _ i \big\ \vert _ 2^2\]

that is, the sum of squared 2D distances between observed image points $\pmb x _ i$ and the predicted projections of the corresponding 3D points $\mathbf X _ i$.

Source: Lecture 14, Camera Calibration: Linear vs. Nonlinear slide.

@bite~ @exam~

What additional modelling does non-linear camera calibration enable compared to the linear method, and what is the standard way to initialise it?

  • Radial distortion: the non-linear loss can incorporate lens-distortion parameters so the model fits real (non-pinhole) lenses.
  • Constraints: known focal length, orthogonality of $\mathbf R$, visibility of points, etc., can be enforced directly in the objective.
  • Initialisation: run linear calibration first, then perform QR-decomposition of $\mathbf P = [\mathbf P _ {1{:}3} \mid \pmb p _ 4]$ to extract initial estimates of $\mathbf K$ and $\mathbf R$, then refine non-linearly.

Source: Lecture 14, Camera Calibration: Linear vs. Nonlinear slide.

@bite~

@Define the weak-perspective camera and explain when it is a good approximation to a perspective camera.

The weak-perspective camera is the limit of perspective projection when the distance from the camera centre to the image plane (focal length / depth ratio) becomes very large — equivalently, the limit as $f \to \infty$ while subject distance also grows so depth variation $\Delta z / z \to 0$.

In this limit the projection becomes essentially $(x, y, z) \mapsto (f \, x / \bar z, \, f \, y / \bar z)$ for a single representative depth $\bar z$, so it acts like a scaled orthographic projection: no perspective foreshortening within the object.

Good approximation when: long focal lengths, faraway subjects, or shallow scenes (object depth small compared to overall distance). The lecture demonstrates this with a sequence of photos of the same building taken at increasing focal lengths — the perspective convergence steadily disappears.

Source: Lecture 14, Approximating an Orthographic Camera slide.

@bite~ @exam~

Parallel lines in 3D space project under perspective to image lines that all meet at a single point called the vanishing point, lying on the image plane in the direction of the parallel family. Lecture 14 illustrates this with Piero della Francesca’s Flagellation of Christ (1455-60).

Source: Lecture 14, Vanishing Points slide.

@bite~

Under perspective projection, the image of a sphere is in general an ellipse (only a circle when the sphere lies on the optical axis). The rays from the camera tangent to the sphere form a cone, and a generic cross-section of that cone with the image plane is elliptical.

Source: Lecture 14, Projection of 3D Shapes slide.

@bite~

In a pinhole camera the projected image is inverted (upside-down and mirrored) — light rays from $P$ pass through the pinhole at the optical centre and hit the image plane behind it. For algebraic convenience we usually pretend the image plane sits in front of the camera at $z = f$, which gives an equivalent upright image and the standard $(x, y, z) \mapsto (fx/z, fy/z)$ formula.

Source: Lecture 14, Perspective Projection and Virtual Image Plane slides.

@bite~

In the intrinsic-parameter calibration matrix $\mathbf K$, the entries $m _ x, m _ y$ have units of pixels per metre and convert from the metric world units used by the focal length $f$ and principal point $(p _ x, p _ y)$ into the pixel units of the final image coordinates.

Source: Lecture 14, Intrinsic Parameters: Scaling Factors slide.

@bite~

@State the strategy for deriving the linear method for camera calibration (∆linear-calibration-derivation), in 4 steps without algebra.

  • Parameterise freely: forget the factored form $\mathbf P = \mathbf K[\mathbf R \mid \pmb t]$ and treat the $3 \times 4$ projection matrix as 12 unknown entries $p _ {ij}$ (11 DoF after the up-to-scale equivalence).
  • Translate each correspondence into linear equations: the projective equality $\pmb x _ i \cong \mathbf P \mathbf X _ i$ kills the unknown scale by cross-multiplying — each 2D-3D pair gives 2 linearly independent rows in the entries of $\mathbf P$.
  • Stack into a homogeneous system: collecting all $n$ correspondences gives $\mathbf A \pmb p = \pmb 0$ with $\mathbf A \in \mathbb R^{2n \times 12}$; need $n \ge 6$ to over-determine the 11 DoF.
  • Solve as homogeneous LS: take $\pmb p$ to be the right singular vector of $\mathbf A$ associated with the smallest singular value (equivalently, the smallest-eigenvalue eigenvector of $\mathbf A^\top \mathbf A$), then reshape back into a $3 \times 4$ matrix.

This is the same “stack-and-SVD” recipe as the homography solve (∆homography-linear-system-solution) and the eight-point algorithm (∆eight-point-algorithm-derivation) — the only differences are the dimensions and the post-solve rank-enforcement step.

Source: Lecture 14, Camera Calibration: Linear Method and Camera Calibration: Full Linear System slides.

@bite~ @proofsupport~

Visualising the projection pipeline

The ∆camera-calibration-decomposition splits projection into extrinsics and intrinsics: a world point becomes a pixel by $p \cong K[R \mid t]P$ (∆camera-projection-matrix-entries). Orbit the third-person view and move the camera with the extrinsic sliders to see how its pose [R|t] changes the photo, then adjust K (focal length, principal point, skew) to see how the same scene maps to different pixels. Focal length sets the field of view, the principal point shifts the image, and skew shears it.

A 3D world point projects to a pixel by \(p \cong K[R|t]P\). The extrinsics \([R|t]\) say where the camera is (its pose): they move the world into the camera frame, \(X_{cam} = R(P - C)\). Perspective divides by depth, \(x = (X/Z, Y/Z)\). The intrinsics \(K\) say how rays become pixels: focal length (zoom / field of view), principal point (image centre), and skew. Drag the left panel to orbit the third-person view; the right panel is the photo the camera takes.

the scene (drag to orbit) · camera with pose \([R|t]\)

the image (pixels) · shaped by \(K\)

Extrinsics [R|t] — camera pose
azimuthelevationdistance
Intrinsics K
focal fpp xpp yskew