# kornia.geometry.homography¶

Module with useful functionalities for homographies manipulation.

kornia.geometry.homography.find_homography_dlt(points1, points2, weights=None)[source]

Compute the homography matrix using the DLT formulation.

The linear system is solved by using the Weighted Least Squares Solution for the 4 Points algorithm.

Parameters
Return type

Tensor

Returns

the computed homography matrix with shape $$(B, 3, 3)$$.

kornia.geometry.homography.find_homography_dlt_iterated(points1, points2, weights, soft_inl_th=3.0, n_iter=5)[source]

Compute the homography matrix using the iteratively-reweighted least squares (IRWLS).

The linear system is solved by using the Reweighted Least Squares Solution for the 4 Points algorithm.

Parameters
• points1 (Tensor) – A set of points in the first image with a tensor shape $$(B, N, 2)$$.

• points2 (Tensor) – A set of points in the second image with a tensor shape $$(B, N, 2)$$.

• weights (Tensor) – Tensor containing the weights per point correspondence with a shape of $$(B, N)$$. Used for the first iteration of the IRWLS.

• soft_inl_th (float, optional) – Soft inlier threshold used for weight calculation. Default: 3.0

• n_iter (int, optional) – number of iterations. Default: 5

Return type

Tensor

Returns

the computed homography matrix with shape $$(B, 3, 3)$$.

kornia.geometry.homography.oneway_transfer_error(pts1, pts2, H, squared=True, eps=1e-08)[source]

Return transfer error in image 2 for correspondences given the homography matrix.

Parameters
• pts1 (Tensor) – correspondences from the left images with shape (B, N, 2 or 3). If they are homogeneous, converted automatically.

• pts2 (Tensor) – correspondences from the right images with shape (B, N, 2 or 3). If they are homogeneous, converted automatically.

• H (Tensor) – Homographies with shape $$(B, 3, 3)$$.

• squared (bool, optional) – if True (default), the squared distance is returned. Default: True

• eps (float, optional) – Small constant for safe sqrt. Default: 1e-08

Return type

Tensor

Returns

the computed distance with shape $$(B, N)$$.

kornia.geometry.homography.symmetric_transfer_error(pts1, pts2, H, squared=True, eps=1e-08)[source]

Return Symmetric transfer error for correspondences given the homography matrix.

Parameters
• pts1 (Tensor) – correspondences from the left images with shape (B, N, 2 or 3). If they are homogeneous, converted automatically.

• pts2 (Tensor) – correspondences from the right images with shape (B, N, 2 or 3). If they are homogeneous, converted automatically.

• H (Tensor) – Homographies with shape $$(B, 3, 3)$$.

• squared (bool, optional) – if True (default), the squared distance is returned. Default: True

• eps (float, optional) – Small constant for safe sqrt. Default: 1e-08

Return type

Tensor

Returns

the computed distance with shape $$(B, N)$$.