calibrate.py
def compute_homography_ims(original: np.array, observed: np.array) -> np.array:
    """Compute the transformation needed to right the observed image.

    The current code is adapted to checkerboard originals. Note that the
    computed homography should be applied to the LATTER image to match the
    FORMER. Sample usage:

    >>> im1 = cv2.imread('images/checkerboard.png')
    >>> im2 = cv2.imread('images/screenshot.png')
    >>> H, im1_pts, im2_pts = compute_homography_ims(im1, im2)
    >>> im1_warped = warp(im2, H)

    :param original: original image projected in h x w x 3
    :param observed: the projection observed in h x w x 3
    :return: homography matrix 3 x 3, original points, observed points
    """
    # termination criteria
    crit = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)

    # convert images and find corners
    original = cv2.cvtColor(original, cv2.COLOR_BGR2GRAY)
    observed = cv2.cvtColor(observed, cv2.COLOR_BGR2GRAY)
    ori_ret, ori_pts3d = cv2.findChessboardCorners(original, (5, 5))
    obs_ret, obs_pts3d = cv2.findChessboardCorners(observed, (5, 5))

    if ori_ret and obs_ret:
        # convert 3d corners to 2d corners
        ori_pts2d = cv2.cornerSubPix(original, ori_pts3d, (11, 11), (-1, -1), crit)
        obs_pts2d = cv2.cornerSubPix(observed, obs_pts3d, (11, 11), (-1, -1), crit)
        ori_pts2d = ori_pts2d.squeeze(1)
        obs_pts2d = obs_pts2d.squeeze(1)
        return compute_homography_pts(ori_pts2d, obs_pts2d), ori_pts2d, obs_pts2d
    return None, None, None
Compute the transformation needed to right the observed image.

    The current code is adapted to checkerboard originals. Note that the
    computed homography should be applied to the LATTER image to match the
    FORMER. Sample usage:

    >>> im1 = cv2.imread('images/checkerboard.png')
    >>> im2 = cv2.imread('images/screenshot.png')
    >>> H, im1_pts, im2_pts = compute_homography_ims(im1, im2)
    >>> im1_warped = warp(im2, H)

    :param original: original image projected in h x w x 3
    :param observed: the projection observed in h x w x 3
    :return: homography matrix 3 x 3, original points, observed points
    
Compute the transformation needed to right the observed image.
The current code is adapted to checkerboard originals. Note that the
computed homography should be applied to the LATTER image to match the
FORMER. Sample usage.


Compute the transformation needed to right the observed image . The current code is adapted to checkerboard originals . Note that the computed homography should be applied to the LATTER image to match the FORMER . Sample usage .
def compute_homography_ims(original: np.array, observed: np.array) -> np.array:
    crit = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
    original = cv2.cvtColor(original, cv2.COLOR_BGR2GRAY)
    observed = cv2.cvtColor(observed, cv2.COLOR_BGR2GRAY)
    ori_ret, ori_pts3d = cv2.findChessboardCorners(original, (5, 5))
    obs_ret, obs_pts3d = cv2.findChessboardCorners(observed, (5, 5))
    if ori_ret and obs_ret:
        ori_pts2d = cv2.cornerSubPix(original, ori_pts3d, (11, 11), (-1, -1), crit)
        obs_pts2d = cv2.cornerSubPix(observed, obs_pts3d, (11, 11), (-1, -1), crit)
        ori_pts2d = ori_pts2d.squeeze(1)
        obs_pts2d = obs_pts2d.squeeze(1)
        return compute_homography_pts(ori_pts2d, obs_pts2d), ori_pts2d, obs_pts2d
    return None, None, None
def compute_homography_ims ( original : np . array , observed : np . array ) -> np . array : crit = ( cv2 . TERM_CRITERIA_EPS + cv2 . TERM_CRITERIA_MAX_ITER , 30 , 0.001 ) original = cv2 . cvtColor ( original , cv2 . COLOR_BGR2GRAY ) observed = cv2 . cvtColor ( observed , cv2 . COLOR_BGR2GRAY ) ori_ret , ori_pts3d = cv2 . findChessboardCorners ( original , ( 5 , 5 ) ) obs_ret , obs_pts3d = cv2 . findChessboardCorners ( observed , ( 5 , 5 ) ) if ori_ret and obs_ret : ori_pts2d = cv2 . cornerSubPix ( original , ori_pts3d , ( 11 , 11 ) , ( - 1 , - 1 ) , crit ) obs_pts2d = cv2 . cornerSubPix ( observed , obs_pts3d , ( 11 , 11 ) , ( - 1 , - 1 ) , crit ) ori_pts2d = ori_pts2d . squeeze ( 1 ) obs_pts2d = obs_pts2d . squeeze ( 1 ) return compute_homography_pts ( ori_pts2d , obs_pts2d ) , ori_pts2d , obs_pts2d return None , None , None
Compute the transformation needed to right the observed image.
Compute the transformation needed to right the observed image .
"""Compute the transformation needed to right the observed image.

    The current code is adapted to checkerboard originals. Note that the
    computed homography should be applied to the LATTER image to match the
    FORMER. Sample usage:

    >>> im1 = cv2.imread('images/checkerboard.png')
    >>> im2 = cv2.imread('images/screenshot.png')
    >>> H, im1_pts, im2_pts = compute_homography_ims(im1, im2)
    >>> im1_warped = warp(im2, H)

    :param original: original image projected in h x w x 3
    :param observed: the projection observed in h x w x 3
    :return: homography matrix 3 x 3, original points, observed points
    """ # termination criteria # convert images and find corners # convert 3d corners to 2d corners
homography matrix 3 x 3, original points, observed points
homography matrix 3 x 3 original points observed points
original
np.array
original image projected in h x w x 3
original image projected in h x w x 3
observed
np.array
the projection observed in h x w x 3
the projection observed in h x w x 3