Estimate the planar homography that maps source points to destination points, , with the normalized Direct Linear Transform.
Implement:
normalize_points(pts): for an (N, 2) array, return (pts_n, T) where is the similarity that translates the centroid to the origin and scales uniformly so the mean Euclidean distance of the points from the origin is : , and pts_n are the transformed points (non-homogeneous, (N, 2)).apply_homography(H, pts): map (N, 2) points through and divide by the third coordinate.dlt_homography(src, dst): for correspondences,
Homographies are only defined up to scale, so return scaled so that . With noisy correspondences the answer is the least-squares solution of this exact procedure; skipping the normalization gives a different (worse) matrix and will not pass.