Camera Calibration
The mapping of 3D coordinates to points in the image is done by a series of two matrices, one of which account for the rotation and translation of points in 3D space, and the other based on camera intrinsics.
Solving for this matrix involves solving for some matrix $M$ which minimizes the error of: \begin{equation*} \begin{bmatrix} mu \\ mv \\ m \end{bmatrix} = M \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix} \end{equation*} for every point \begin{bmatrix} x & y & z \end{bmatrix} and its corresponding point \begin{bmatrix} u & v \end{bmatrix} in the image. The calculation is done by least squares since the system is over-determined after \(6\) points and is very similar to the homography matrix calculation.