Skip to content

Instantly share code, notes, and snippets.

@emnak
Last active October 27, 2020 15:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emnak/5ae2637c9ee08d9620ed21215441ee25 to your computer and use it in GitHub Desktop.
Save emnak/5ae2637c9ee08d9620ed21215441ee25 to your computer and use it in GitHub Desktop.
# Select good matched keypoints
ref_matched_kpts = np.float32([kp1[m[0].queryIdx].pt for m in good_matches])
sensed_matched_kpts = np.float32([kp2[m[0].trainIdx].pt for m in good_matches])
# Compute homography
H, status = cv.findHomography(sensed_matched_kpts, ref_matched_kpts, cv.RANSAC,5.0)
# Warp image
warped_image = cv.warpPerspective(img2, H, (img2.shape[1], img2.shape[0]))
cv.imwrite('warped.jpg', warped_image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment