Q1: Camera matrix P from 2D-3D correspondences

Implementation

For each image point, obtain two constraints where:

[0wXyXwX0xX]p=0 \begin{bmatrix} \textbf{0} & -w\textbf{X}^\intercal & y\textbf{X}^\intercal \\ w\textbf{X}^\intercal & \textbf{0} & -x\textbf{X}^\intercal \\ \end{bmatrix} p = \textbf{0}

Solve for vector of coefficients based on these constraints using the smallest singular value from SVD. Reshape the 12 parameters into a 3×43 \times 4 matrix to obtain PP.

(a) Stanford bunny

Input image

Output image

(b) Cuboid

Input image

Output image