Assignment 1
Omar Alama (oalama)
Q1: Affine Rectification (30 points)





Angle evaluation of another pair of lines
Homography is computed using given annotations as shown in previous section. Before and after cosines are computed with another set of parallel lines (Not used for homography computation).

[1] Before: 0.9935 After: -0.9983
[2] Before: 1.0000 After: 1.0000

[1] Before: 0.9922 After: 1.0000
[2] Before: 0.9938 After: 0.9998

[1] Before: 0.9375 After: 1.0000
[2] Before: 1.0000 After: 0.9994
Algorithm used.
- Cross product between first two points to get first line, similarly to the second line. Then cross product between the line pair to get the point at infinity.
- Repeat for the next pair.
- Cross product between the two points at infinity to get the line at infinity.
- Normalize by last element to avoid numbers blowing up.
- Construct the transformation using the image of the line at infinity as
[1, 0, 0],
[0, 1, 0],
[l1,l2,l3]
- Warp using utils.
Q2: Metric Rectification (40 points)





Angle evaluation of another pair of lines
Homography is computed using given annotations as shown in previous section. Before and after cosines are computed with another set of orthogonal lines (Not used for homography computation).

[1] Before: -0.5603 After: -0.0212
[2] Before: -0.7198 After: -0.0096

[1] Before: -0.3505 After: -0.0193
[2] Before: -0.6161 After: 0.0296

[1] Before: 0.2090 After: -0.0081
[2] Before: 0.0961 After: -0.0293
Algorithm
- Perform affine rectification as described in Q1 such that all annotations and points are now affinely rectified.
- Construct constraint matrix from two pairs of orthogonal lines where each pair gives a constraint
[l1*m1, l1*m2+l2*m1, l2*m2]s = 0
where s = (s11, s12, s22) elements of the 4x4 symmetric S matrix.
- Compute SVD of constraint matrix to get the null vector solution for s.
- Use s to construct S and the image of the dual absolute conic where S is the top left 2x2 elements and the rest are zeros.
- Compute SVD of the dual conic and construct the projectivity transform as H
H=[sqrt(1/sigma1),0,0],[0,sqrt(1/sigma2),0],[0,0,1]] @ U.T
where @ is matrix multiplication and U.T is the right singular vectors transposed obtained from the SVD.
- Use the resulting H to metricly rectify
Q3: Planar Homography from Point Correspondences (30 points)


Algorithm
Each point gives two constraints on the 9x1 vector h.
The two constraints can be described as the two rows:
[zero_v, -dst_homo_pt[2]*src_homo_pt, dst_homo_pt[1]*src_homo_pt]
[dst_homo_pt[2]*src_homo_pt, zero_v, -dst_homo_pt[0]*src_homo_pt]
Having 4 points lets us concatenate 8 constraints into an 8x9 matrix A yielding an equation
Ah=0
Then we compute SVD and take the last right null vector and reshape it to 3x3 matrix.
Finally, I normalize H by H[3,3] to obtain H and use the provided utils to warp the image using that H.