我有两张照片 . 一个原始img1和另一个相同的图像,但挤压img2 .
我使用SIFT和FLANN匹配器提取并匹配了两者之间的功能 . https://i.imgur.com/9WzEAKm.png .
我还根据以下代码中的匹配功能找到了Homography .

src_pts = np.float32([kp1[m.queryIdx].pt for m in good]).reshape(-1, 1, 2)

dst_pts = np.float32([kp2[m.trainIdx].pt for m in good]).reshape(-1, 1, 2)

M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC, 5.0)

所以我的问题是,如何使用该Homography将img2转换为img1,或尽可能接近它?我使用了cv2.warpPerspective(),但结果图像非常奇怪 .

img2_warped = cv2.warpPerspective(img2, M, img1.shape)

https://i.imgur.com/WKybXZs.png

我该怎么办?