calibrate.py
def compute_homography_pts(pts1: np.array, pts2: np.array) -> np.array:
    """Compute homography between two sets of points.

    Gracefully handles sets with different numbers of points, by ignoring
    extras in the larger of the two sets. The computed homography represents
    a change of basis FROM the latter points to the FORMER.

    :param pts1: First set of points n x 2
    :param pts2: Second set of points n x 2
    :return: homography matrix 3 x 3
    """
    A = []
    b = pts2.reshape(-1, 1)
    for (x1, y1), (x2, y2) in zip(pts1, pts2):
        A.append([x1, y1, 1, 0, 0, 0, -x1 * x2, -y1 * x2])
        A.append([0, 0, 0, x1, y1, 1, -x1 * y2, -y1 * y2])
    A = np.array(A)
    H_8 = np.linalg.pinv(A.T.dot(A)).dot(A.T).dot(b)
    return np.vstack((H_8, 1)).reshape(3, 3)
Compute homography between two sets of points.

    Gracefully handles sets with different numbers of points, by ignoring
    extras in the larger of the two sets. The computed homography represents
    a change of basis FROM the latter points to the FORMER.

    :param pts1: First set of points n x 2
    :param pts2: Second set of points n x 2
    :return: homography matrix 3 x 3
    
Compute homography between two sets of points.
Gracefully handles sets with different numbers of points, by ignoring
extras in the larger of the two sets. The computed homography represents
a change of basis FROM the latter points to the FORMER.
Compute homography between two sets of points . Gracefully handles sets with different numbers of points by ignoring extras in the larger of the two sets . The computed homography represents a change of basis FROM the latter points to the FORMER .
def compute_homography_pts(pts1: np.array, pts2: np.array) -> np.array:
    A = []
    b = pts2.reshape(-1, 1)
    for (x1, y1), (x2, y2) in zip(pts1, pts2):
        A.append([x1, y1, 1, 0, 0, 0, -x1 * x2, -y1 * x2])
        A.append([0, 0, 0, x1, y1, 1, -x1 * y2, -y1 * y2])
    A = np.array(A)
    H_8 = np.linalg.pinv(A.T.dot(A)).dot(A.T).dot(b)
    return np.vstack((H_8, 1)).reshape(3, 3)
def compute_homography_pts ( pts1 : np . array , pts2 : np . array ) -> np . array : A = [ ] b = pts2 . reshape ( - 1 , 1 ) for ( x1 , y1 ) , ( x2 , y2 ) in zip ( pts1 , pts2 ) : A . append ( [ x1 , y1 , 1 , 0 , 0 , 0 , - x1 * x2 , - y1 * x2 ] ) A . append ( [ 0 , 0 , 0 , x1 , y1 , 1 , - x1 * y2 , - y1 * y2 ] ) A = np . array ( A ) H_8 = np . linalg . pinv ( A . T . dot ( A ) ) . dot ( A . T ) . dot ( b ) return np . vstack ( ( H_8 , 1 ) ) . reshape ( 3 , 3 )
Compute homography between two sets of points.
Compute homography between two sets of points .
"""Compute homography between two sets of points.

    Gracefully handles sets with different numbers of points, by ignoring
    extras in the larger of the two sets. The computed homography represents
    a change of basis FROM the latter points to the FORMER.

    :param pts1: First set of points n x 2
    :param pts2: Second set of points n x 2
    :return: homography matrix 3 x 3
    """
homography matrix 3 x 3
homography matrix 3 x 3
pts1
np.array
First set of points n x 2
First set of points n x 2
pts2
np.array
Second set of points n x 2
Second set of points n x 2