Q1: Camera matrix P from 2D-3D correspondences
Implementation
For each image point, obtain two constraints where:
- p is the 12 element linearized camera matrix P
- x and y are the image coordinates with homogeneous component w
- X is the corresponding homogeneous 3D object point
[0wX⊺−wX⊺0yX⊺−xX⊺]p=0
Solve for vector of coefficients based on these constraints using the smallest singular value from SVD. Reshape the 12 parameters into a 3×4 matrix to obtain P.
(a) Stanford bunny

Output image

(b) Cuboid

Output image
