\subsection{Cameras} \shortdefinition[Pinhole projection] $\begin{bmatrix} u & v \end{bmatrix}^\top = \frac{f}{z} \begin{bmatrix} x & y \end{bmatrix}^\top$ with $f$ the distance to the lens and $z$ the full distance \newpage $u = c_u + f \cdot x'$ and $v = c_v + f \cdot y'$ where $x' = t_x \div t_z$ and $y' = t_y \div t_z$ where $u, v$ are the pixel $x, y$ coords, $\vec{c} = [c_u, c_v]^\top$ is optical centre of cam in pixel coords, $f$ scale factor, and $\vec{{_C}\vec{t}_P} = [t_x, t_y, t_z]^\top$ The full proj: $\vec{u} = \begin{bmatrix} \lambda u \\ \lambda v \\ \lambda \end{bmatrix} = \begin{bmatrix} f & 0 & c_u \\ 0 & f & c_v \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} t_x \\t_y\\t_z \end{bmatrix} = \mat{K}\; {_C}\vec{t}_P$ If p. in diff frame ${_W} \vec{t}_P$, then $\vec{u} = \mat{K}[\mat{R}_{CW}\; {_C}\vec{t}_{CW}] = {_W}\vec{t}_P$ \subsubsection{Pinhole Camera Projection with distortion} \shortdefinition Model: $\vec{u} = \vec{k}(\vec{d}(\vec{p}({_C}\vec{t}_P)))$, with: (Projection) $\vec{x'} = \vec{p}({_C}\vec{t}_P) = t_z^{-1} \cdot [t_x, t_y]^\top$ (Distortion model, $r^2 = x'^2 + y'^2$, $\vec{x''} = \vec{d}(\vec{x'})$\\ $\vec{x''} = \! \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} \vec{x'} + \begin{bmatrix} 2p_1 x' y' + p_2(r^2 + 2x'^2) \\ p_1 (r^2 + 2y'^2) + 2p_2 x'y' \end{bmatrix}$ (Scale and Centre) $\vec{u} = \vec{k}(\vec{x''}) = \text{diag}([f_u, f_v]) \cdot \vec{x''} + \vec{x}$ All with $k_i$ radial distortion params, optional for $i > 2$, $p_i$ tang. dist. param, $f_u, f_v$ focal length in pixels \shade{green}{Inverse} ${_C}\vec{r} = [\vec{d}^{-1}(\vec{k^{-1}(\vec{u})}), 1]^\top$\\ (To unit plane) $\vec{x''} = \vec{k}^{-1}(\vec{u}) = [f_u^{-1}, f_v^{-1}]^\top (\vec{u} - \vec{c})$ (Un-distort) $\vec{x'} = \vec{d}^{-1}(\vec{x''})$ (usually comp. numerically) (Compute ray) ${_C}\vec{r} = [\vec{x'}, 1]^\top$ \subsubsection{Undestorting a whole image} $\vec{u}_i = \vec{k}(\vec{d}(\vec{k_{\text{new}}}^{-1}(\vec{u}_{i, \text{new}})))$ where $\vec{u}_{i, \text{new}}$ is the place of pixel in output, $\vec{u}_i$ is the input \bi{Omnidir. Cam} undistortion model with $f(u, v) = \sum_{i = 0}^{N} a_i \rho^i$ with $\rho = \sqrt{(u - c_u)^2 + (v - c_v)^2}$, $N = 4$ accurately describes it for most fisheye and catadioptric cameras