All problems
Homography from 4 Correspondences
Problem
Fit a 3x3 homography from four point correspondences with the DLT and h22 = 1.
Build the 8x8 linear system from pairs (x, y) -> (u, v), solve it with Gaussian elimination and return the homography with each entry rounded to 4 decimal places. Points are in general position.
Hint
Each correspondence gives two rows: one for u and one for v.
Test cases
case 1
in: [[[0,0],[1,0],[1,1],[0,1]],[[0,0],[1,0],[1,1],[0,1]]]
expected: [[1,0,0],[0,1,0],[0,0,1]]
case 2
in: [[[0,0],[1,0],[1,1],[0,1]],[[2,3],[3,3],[3,4],[2,4]]]
expected: [[1,0,2],[0,1,3],[0,0,1]]
case 3
in: [[[0,0],[1,0],[1,1],[0,1]],[[0,0],[2,0],[2,2],[0,2]]]
expected: [[2,0,0],[0,2,0],[0,0,1]]
case 4
in: [[[0,0],[2,0],[2,2],[0,2]],[[0,0],[2,0],[1.6667,1.6667],[0,2]]]
expected: [[1.25,0,0],[0,1.25,0],[0.125,0.125,1]]
Starter codePython
def homography_from_points(src, dst):
# Your code here
pass4 test cases · run your code against them in the editor