Homework 2
Q1. (a) Stanford Bunny
         

Input

                                                                

Surface Points

                                 

Bounding Box

Image 1 Image 1 Image 1

P:

                [-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.51654831e-05 1.35588807e-04 7.00171505e-05 -9.52266452e-05]
            
Q1. (b) Cube
         

Input

                                                                

Annotated Points

                                 

Edges

Image 1 Image 1 Image 1

P:

            [ 1.66044955e-01 8.46973794e-02 -6.15202183e-02 6.41781424e-01]
            [-5.23843891e-03 -5.40700067e-02 -2.26155715e-01 7.03910118e-01]
            [ 9.95432328e-06 8.14100497e-05 -8.70206259e-05 6.40280356e-04]
        

Q2. (a) Camera calibration from vanishing points
         

Annotations

                                        

Vanishing Points and Principal Point

                
Image 1 Image 1

Obtained K:

                [ 1.15417802e+03  0.00000000e+00  5.75066005e+02 ]
                [-1.63892221e-13  1.15417802e+03  4.31939090e+02 ]
                [-0.00000000e+00  0.00000000e+00  1.00000000e+00 ]
            

Method:

  1. Compute the vanishing points (VPs) using the parallel lines: vp = cross(line1, line2), normalize by dividing by the last coordinate.
  2. For each pair of VPs, form constraints: [x1 * x2 + y1 * y2, x1 + x2, y1 + y2, 1].
  3. Solve the system using SVD: U, S, Vt = svd(A), with the IAC being the last row of Vt.
  4. The IAC is constructed as:
                        [ω₀, 0, ω₁], 
                        [0, ω₀, ω₂], 
                        [ω₁, ω₂, ω₃]
                    
    .
  5. Extract the intrinsic matrix K from the IAC via Cholesky decomposition.
Q2. (b) Camera calibration from metric planes
         

Input

                                                                

Annotated Points

                
Image 1 Image 1

Obtained K:

            [ 1.08447642e+03 -1.35121131e+01  5.20013594e+02]
            [ 1.97287261e-13  1.07900526e+03  4.02544642e+02]
            [-0.00000000e+00 -3.69125115e-18  1.00000000e+00]
        
            Angle between plane 0 and plane 1:  67.57512638792475
            Angle between plane 0 and plane 2:  92.24721700765527
            Angle between plane 1 and plane 2:  94.78379189499219
        

Method:

  1. Calculate the homography between the four image points and the coordinates (0, 0), (0, 1), (1, 0), and (1, 1) of the three squares.
  2. For each homography matrix H, extract the first two columns h1 and h2
  3. Form two constraints for each homography. From the condition h₁ᵀ ω h₂ = 0, form the equation:
    [x₁ * x₂, x₁ * y₂ + x₂ * y₁, y₁ * y₂, x₁ * z₂ + x₂ * z₁, y₁ * z₂ + y₂ * z₁, z₁ * z₂]
    From the condition h₁ᵀ ω h₁ = h₂ᵀ ω h₂, form the equation:
    [x₁² - x₂², 2(x₁ * y₁ - x₂ * y₂), y₁² - y₂², 2(x₁ * z₁ - x₂ * z₂), 2(y₁ * z₁ - y₂ * z₂), z₁² - z₂²]
    .
  4. Construct matrix A from the constraints and solve using Singular Value Decomposition (SVD): U, S, Vt = svd(A).
  5. The last row of Vt gives the solution ω, the elements of the IAC.
  6. The IAC is constructed as:
            [
                [ω₀, ω₁, ω₃], 
                [ω₁, ω₂, ω₄], 
                [ω₃, ω₄, ω₅]
            ]
            
    .
  7. Extract the intrinsic matrix K from the IAC via Cholesky decomposition.
Q3. Single View Reconstruction
         

Input

                                        

Annotated Points

                

Reconstruction View 1

                

Reconstruction View 2

                       
Image 1 Image 1 Image 1 Image 1

Obtained K:

            [ 8.09951409e+02  0.00000000e+00  5.10720088e+02]
            [-3.48409833e-14  8.09951409e+02  3.56268955e+02]
            [-0.00000000e+00  0.00000000e+00  1.00000000e+00]
        

Method:

  1. Vanishing Points and Intrinsic Matrix Calculation:
    • Calculate vanishing points (VPs) by intersecting lines from the annotations.
    • From the VPs, compute the Image of the Absolute Conic (IAC) similar to Q2 (a).
    • Obtain the intrinsic matrix K using Cholesky decomposition on the IAC.
  2. First Plane Calculation:
    • Convert the first annotation point to a 3D ray using pt1_ray = inv(K) * [x, y, 1].
    • Compute the normals of all the planes using the vanishing directions and the intrinsic matrix n = np.cross(d1, d2)
    • Define the first plane equation using the normal and a reference 3D point plane1 = [nx, ny, nz, d], where d = -dot(normal, pt1_3d).
  3. Other Planes Calculation:
    • Use the first plane to back-project its corners of the image to 3D space.
    • For each remaining rectangle, compute the plane using its normal and one common corner. Plane equation: plane = [nx, ny, nz, -dot(normal, corner_3d)].
  4. Projecting Points:
    • Obtain pixel coordinates in each rectangle and compute their 3D position by projecting along the ray: point3d = -ray * d / dot(ray, normal).
  5. Visualization:
    • After projecting all points, scatter them in 3D space along with their color information.
Q3. (b) More reconstructions

Note: Couldn't capture GIFs due to rendering lag.

Self Captured Image

         

Input

                                        

Annotated Points

                
Image 1 Image 1
         

Reconstructed View 1

                                               

Reconstructed View 2

                                        

Reconstructed View 3

Image 1 Image 1 Image 1

Image from the Internet

         

Input

                                        

Annotated Points

                
Image 1 Image 1
         

Reconstructed View 1

                                               

Reconstructed View 2

                                        

Reconstructed View 3

Image 1 Image 1 Image 1

Stable Diffusion Generated Image

Image 1 Image 1
         

Reconstructed View 1

                                               

Reconstructed View 2

                                        

Reconstructed View 3

Image 1 Image 1 Image 1