Q1: Affine Rectification

1.1 Output Images and Angle Evaluation Results:

pic1

Before After
0.9801935239283572 0.9999413201351588
0.9077385010215981 0.9982815650684259

pic1

Before After
0.9954293641543964 0.9999413201351588
0.9964914336529828 0.9999752424843763

pic1

Before After
0.9928400002003689 0.9999744329310002
0.9958562285955483 0.9995508549532741

pic1

Before After
0.9868327646462675 0.9999251970022865
0.9987191070813484 0.9999383464088631

pic1

Before After
0.7842324298864688 0.999978139517972
0.9999970152053781 0.9999869448826936

1.2 Implementation Description

Use the annotated points to get two pairs of parallel lines. Use $x=l_1$x$l_2$ to get the intersection of two lines. Use $x_1$x$x_2$ to get the line at infinite. Then, we can compute H with:

$l=H^{-T}l'$, l refers to the line at infinite, $l=[l_1,l_2,l_3]^{-T}$.

We get one solution H=$$ \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ l_{1} & l_{2} & l_{3} \end{bmatrix} $$

Q2: Metric Rectification

2.1 Output Images and Angle Evaluation Results:

pic1

Before After
-0.10272308450664172 0.05650143872109491
0.45958021577399355 0.01784973627322923

pic1

Before After
0.43166311591881273 0.09891134391597332
0.416638993307934 0.06254952999238895

pic1

Before After
-0.2526709009836574 0.0018168249234062953
0.08817394212374821 0.008198536236441723

pic1

Before After
0.1677181548716634 -0.008091866263126083
0.03498266075814032 -0.029306932732914674

pic1

Before After
0.6685881410241951 -0.021182064318718698
-0.04479521389935166 -0.009640234139807519

2.2 Implementation Description

According to $$ l' C_\infty^{*'} M' = 0 $$, use SVD to get the solution of AC=0 (image is already affine-rectified)

Then use SVD for $ C_\infty^{*'} $ and get 2 Non-zero eigenvalues.

$$ C_\infty^{*'} = U \begin{bmatrix} \sigma_1 & 0 & 0 \\ 0 & \sigma_2 & 0 \\ 0 & 0 & 0 \end{bmatrix} U^T $$

With $C_\infty^{*} =HC_\infty^{*'} H^{T}$, we get $$ H= \begin{bmatrix} \sqrt{\sigma_1} & 0 & 0 \\ 0 & \sqrt{\sigma_2} & 0 \\ 0 & 0 & 1 \end{bmatrix} U^T $$

Q3: Planar Homography from Point Correspondences

3.1 Output:

pic1

pic1

3.2 Implementation Description:

With x'=Hx, we know that H can be solved in Ah=0, where A_i=\begin{bmatrix} x_2^i & y_2^i & 1 & 0 & 0 & 0 & -x_1^i x_2^i & -x_1^i y_2^i & -x_1^i \\ 0 & 0 & 0 & x_2^i & y_2^i & 1 & -y_1^i x_2^i & -y_1^i y_2^i & -y_1^i \end{bmatrix}

Then get the solution H with eigenvalues decomposition of A.

Q5: Bonus: More Planar Homography from Point Correspondences

5.1 Output

pic1

5.2 Implementation Description:

Expand the situation in Q3 to take 12 points and then perform homography on each of them.