- CalculateHomography.cs is for all the functions,
- Part1.cs is for the test and log.
Write a C# function that given a set of point correspondences ππ=[π₯ππ¦π]π and πΌπ=[π’ππ£π]π calculates the corresponding homography matrix.You can assume that there are equal number of points for ππ and πΌπ and they are in correspondence. This function should use a non-linear optimization method to calculate the homography.
- I used 4 source points and 4 image points and used the Ah = 0 formula. Then, SVD function is applied to Matrix A. I used the VT matrix from the SVD and got its transpose. Finally, the result Homography Matrix is the 3x3 matrix arranged from the last row of the transposed matrix.
Write another C# function that given a scene point [π₯ππ¦π] and a homography matrix, calculates the projection of the given point onto the target image.
- I used an example point as a scene point. I used the homography matrix to transform the coordinates onto the target image. This is made by multiplying the homography matrix by a matrix containing the coordinates of the scene point. The result of the multiplication is the matrix containing the projected coordinates.
Write another C# function that given an image point [π’ππ£π] and a homography matrix, calculates the projection of the given point ontothe scene.
- I used an example point as an image point. I used the inverse of the homography matrix to transform the coordinates onto the scene. This is, again, made by multiplying the homography matrix by a matrix containing the coordinates of the image point. The result of the multiplication is the matrix containing the projected coordinates.