Name: Gangadhar Nageswar
Andrew ID: vnageswa
Late Days Used: 2

Question 1 : Camera Projection Matrix

1a. Stanford Bunny

Input Image
Description of GIF
Surface Points
Description of GIF
Bounding Box
Description of GIF

Projection Matrix:
[[ 6.12468612e-01, -2.80769806e-01, 1.09185025e-01, 2.12092927e-01],
[-8.90197009e-02, -6.43243106e-01, 1.93261536e-01, 1.73520830e-01],
[ 5.51654830e-05, -1.35588807e-04, -7.00171505e-05, 9.52266452e-05]]

1b. Cuboid

Input image
Description of GIF
Annotated Points
Description of GIF
Bounding Box
Description of GIF

Question 2 - Camera calibration K from annotations

Q2a. Camera calibration from vanishing points

Input Image
Description of GIF
Annotated Lines
Description of GIF
Vanishing Points and Principal Point
Description of GIF

Intrinsic Matrix:
[[ 1.15417802e+03, 0.00000000e+00, 5.75066005e+02],
[ 0.00000000e+00, 1.15417802e+03, 4.31939090e+02],
[ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]]

Implementation details:
- Extract vanishing points from pairs of parallel lines.
- Formulate matrix A using vanishing points similar to the formulation in metric rectification.
- Perform SVD on matrix A to find the omega matrix (IAC).
- Assume that the camera has zero skew, and that the pixels are square.
- Therefore, w11 = w22 and w12 = w21 = 0.
- Use Cholesky decomposition to compute the intrinsic matrix K.
- Normalize the intrinsic matrix with the last element (3,3)
- Visualize vanishing points and principal point on the image.
Important Equations:
1. For

First we obtain the vanishing points. For obtaining the omega (IAC) matrix under the assumption that camera has zero skew, and that the pixels are square, we require atleast a 3 constraints
Procedure:
1. First we compute the vanishing points from pairs of parallel lines.
2. Formulate matrix A using vanishing points similar to the formulation in metric rectification.
3. Perform SVD on matrix A to find the omega matrix (IAC).
4. Assume that the camera has zero skew, and that the pixels are square.
5. Therefore, w11 = w22 and w12 = w21 = 0.
6. Use Cholesky decomposition to compute the intrinsic matrix K.
7. Normalize the intrinsic matrix with the last element (3,3)
8. Visualize vanishing points and principal point on the image.
Key equations:
1. W matrix for the assumed camera matrix can be represented as, w = [w1, 0, w2; 0, w1, w3; w2, w3, w4]
2. If l1 is a vanishing point1 and l2 is the vanishing point 2, then l1.T @ w @ l2 = 0
3. Stacking all the three constraints, we get A @ w_flat = 0
where w_flat = [w1, w2, w3, w4].
4. Each row of A will be [l1[0]*l2[0] + l1[1]*l2[1], l1[0]*l2[2] + l1[2]*l2[0], l1[1]*l2[2] + l1[2]*l2[1], l1[2]*l2[2]]. Stack up all the rows to get A.
5. SVD of A will provide w_flat = [w1, w2, w3, w4] which forms the w (IAC) matrix.

6. W = L @ L.T where L is the Cholesky decomposition of W.
7. Intrinsic matrix K = inv(L.T)

Q2b. Camera calibration from metric planes

Input Image
Description of GIF
Annotated Square 1
Description of GIF
Annotated Square 2
Description of GIF
Annotated Square 3
Description of GIF

Intrinsic Matrix:
[[ 1.08447642e+03, -1.35121131e+01, 5.20013594e+02],
[ 0.00000000e+00, 1.07900526e+03, 4.02544642e+02],
[ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]]

Implementation details:
- Compute the homography for the three metric planes from src_points as corners of unit square.
- Formulate matrix A using the homography matrix columns.
- Perform SVD on matrix A to find the omega matrix (IAC).
- Note that there is no assumption on the camera intrinsic matrix.
- Use Cholesky decomposition to compute the intrinsic matrix K.
- Normalize the intrinsic matrix with the last element (3,3)
- Visualize vanishing points and principal point on the image.
Key equations:
1. W matrix for the assumed camera matrix can be represented as, w = [w11, w12, w13; w21, w22, w23; w31, w32, w33]
2. If H_{1} is the homography for the first plane, where H_{1} = [h1, h2, h3], then h1.T @ w @ h2 = 0 and h1.T @ w @ h1 = h2.T @ w @ h2
3. Stacking all the six constraints (2 from each plane), we get the matrix A.
4. SVD of A will provide w_flat = [w1, w2, w3, w4] which forms the w (IAC) matrix.

5. W = L @ L.T where L is the Cholesky decomposition of W.
6. Intrinsic matrix K = inv(L.T)

Angles between the planes (degrees):

Plane 1 and Plane 2 : 67.58 degrees

Plane 2 and Plane 3 : 94.78 degrees

Plane 1 and Plane 3 : 92.25 degrees

Q2c. Camera calibration from rectangular planes

Input Image
Description of GIF
Annotated Square 1
Description of GIF
Annotated Square 2
Description of GIF
Annotated Square 3
Description of GIF
Principal Point
Description of GIF

Intrinsic Matrix:
[[1.13215411e+03, 6.87406575e+01, 5.47312078e+02],
[0.00000000e+00, 1.02411710e+03, 6.86235324e+02],
[0.00000000e+00, 0.00000000e+00, 1.00000000e+00]]

Angles between the planes (degrees):

Plane 1 and Plane 2 : 81.29 degrees

Plane 2 and Plane 3 : 79.52 degrees

Plane 1 and Plane 3 : 87.63 degrees

Question 3 - Single View Reconstruction

Input Image
Description of GIF
Annotated Planes
Description of GIF
Reconstruted View 1
Description of GIF
Reconstructed View 2
Description of GIF

For computing the homography between two images, we need a minimum of 4 correspondences.

Procedure:
1. Use the three perpendicular set of parallel lines from the first two planes to obtain the intrinsic matrix K.
2. From the annotations of the planes, obtain the pixel points which lie inside the planes.
3. Assume the world coordinates of the 2nd corner of the first plane to be situated at a unit distance. 4. Estimate the 3D world coordinates of the reference base point using intrinsic matrix, pixel coordinates and the unit distance assumption.
5. We need to compute the normal direction of the plane in world. For this obtain the vanishing points of the two set of parallel lines.
6. Obtain the directions of the plane edges using the intrinsic matrix and the vanishing points. Get plane normal from these directions.
7. Obtain the constant offset in the plane equation by substituting the world coordinates of the reference base point in the plane equation.
8. Cast rays for each pixel inside the plane and find its intersection with the plane. Assign the color of the pixel to the 3D world point
9. Repeat the same for all the planes.

Key equations:
1. Plane equation: n.T @ X + a = 0
2. Dir of line with vanishing point v = inv(K) @ v
3. Normal of the plane with vanishing points v1, v2 = cross(inv(K) @ v1, inv(K) @ v2)
4. Ray passing through the pixel p = inv(K) @ p