Camera calibration (source code)

= Camera calibration

<Camera calibration> estimates the parameters relating points in a scene to measured image coordinates. In the ideal pinhole model,
$$
s\begin{pmatrix}u\\v\\1\end{pmatrix}=K\begin{bmatrix}R&t\end{bmatrix}\begin{pmatrix}X\\Y\\Z\\1\end{pmatrix},
$$
where $K$ contains <focal lengths> and the principal point, while the <rotation matrix> $R$ and <translation> $t$ locate the camera relative to the scene. Lens distortion requires additional parameters.<Camera Calibration and 3D Reconstruction by OpenCV>[Detailed Description, pinhole model and distortion coefficients]{ref}

A calibration experiment photographs a flat board with a known grid from several orientations. Detected grid corners provide image measurements; their known spacing supplies geometric constraints and a length scale. Parameters are fitted by minimizing <reprojection error>. Multiple orientations help separate camera geometry from board pose. For an ideal camera with focal length 1000 pixels, a point displaced $0.1\,\mathrm m$ sideways at depth $2\,\mathrm m$ projects 50 pixels from the principal point.<Camera Calibration and 3D Reconstruction by OpenCV>[calibrateCamera, planar-pattern initialization and reprojection error]{ref}