Assignment 2
Andrew ID: roshanr
Late Days: 2
1. Camera matrix P from 2D-3D correspondences
Bunny
[ 4.06890104e+03 -1.82737181e+03 7.89101392e+02 1.42362371e+03]
[-6.46096808e+02 -4.29789393e+03 1.36401935e+03 1.16583711e+03]
[ 3.41890021e-01 -8.80611490e-01 -4.47623375e-01 6.39128040e-01]
Cuboid
Sampled 3D points projected onto the image!
Recovered P
[ 11.07030137 1.50335467 -0.37252062 74.00494539]
[ 0.19740798 0.08010682 -6.95123336 141.13111233]
[ 0.00058421 0.00676127 -0.00232587 1. ]
2. Camera Calibration K from Annotations
PART (a)
Recovered K
[ 1.15417802e+03 0.00000000e+00 5.75066005e+02]
[-0.00000000e+00 1.15417802e+03 4.31939090e+02]
[ 4.45651455e-16 0.00000000e+00 1.00000000e+00]
Implementation
- Vanishing Points Calculation
- For each pair of points, calculate the parallel lines, as . The intersection of the parallel lines results in a vanishing point . Do the same for the other two vanishing points to get .
- Image of absolute conic () Calculation
is of the form:
Since pixels are square and have 0 skew, and has 3 degrees of freedom (-1 for scale ambiguity). We must obtain 3 constraints to recover .
The three vanishing points are pair-wise orthogonal to each other. All pairs satisfy
Three pairs of orthogonal points provide three pairs of constraints, and we get a system of equations for the form:
is calculated as the right singular vector of the matrix
- Recover K from
Perform Cholesky decomposition to get where
PART (b): Camera calibration from metric planes
Recovered K
[ 1.07692614e+03 -4.52638065e+00 5.11568923e+02]
[ 1.19275729e-13 1.07626752e+03 3.95526278e+02]
[ 4.67331363e-16 -1.82919671e-18 1.00000000e+00]
Angle between planes 0 and 1: 67.282425264
Angle between planes 1 and 2: 92.203485588
Angle between planes 2 and 3: 94.710693016
Implementation
- We are given multiple metric planes. We must calculate the homography that takes the square defined at to the annotated points on the image square.
- For a given square with calculated homography
Set and calculate based on the constraints.
Let and then we get the equations
We need three point pairs to provide 6 constraints, and we get a system of equations of the form:
- Recover K from the same way as the previous question
- Angle between planes calculation:
- Find the normal vector that characterizes both planes.
Given vanishing points are of two sets of parallel lines:
Angle between 2 planes is the angle between their normals
- Find the normal vector that characterizes both planes.
PART (c) Camera calibration from rectangles with known sizes
3. Single View Reconstruction
Recovered K
[809.95140903 0. 510.72008772]
[ -0. 809.95140903 356.2689548 ]
[ -0. 0. 1. ]
Implementation
- Calculate the K matrix using Q2a. Use 3 pairs of parallel lines from planes 1 and 2.
- Calculate the normal direction of each plane from Q2b.
- Compute the intercept of each plane by choosing a corner, calculating the direction of the ray passing through the corner, and setting the 3d depth as 1 unit along that direction.
- Using the plane normal direction, plane intercept, and known 3d depth of the corner point , calculate the plane equation
- Compute the 3D coordinate of all points on the plane, via ray-plane intersection of each ray with the plane equation.
- Repeat the process for other planes. We do not need to ground a new point on each plane as there are some common points between the planes.