I've been trying to figure out how to get a birds-eye view of a scene by using a homography and then warping the image. The image that I am trying to warp is linked below, with the points selected with blue circles around them. I have seen advice from similar posts that I need to make sure the points are ordered correctly, and I have tried different orderings of the object points, but the result still has the same weird error.
The image points were selected manually, and you can see that the floor tile is close to a square in the output, as desired.
I believe the problem is with the homography matrix, as when the homography matrix is applied to the corners of the image, they end up at the pixel locations that they are in the output. As all corners are in the image, the standard method of calculating the corners of the image to get the full result as described in this post are not helpful.
Any help would be appreciated! The input image is:
The code used to produce this is included below.
import cv2
import numpy as np
img = cv2.imread('test4_frame.png')
img_circled = img.copy()
im_pts = np.array([[659, 618], [779, 662], [542, 654], [661, 707]], np.float32)
for pt in im_pts:
cv2.circle(img_circled, (pt[0], pt[1]), 10, 255)
cv2_imshow(img_circled)
obj_pts = np.array([[1500, 1500], [1550, 1500], [1500, 1550], [1550, 1550]], np.float32)
H = cv2.findHomography(im_pts, obj_pts)[0]
out = cv2.warpPerspective(img, H, (4000, 4000))
cv2_imshow(out)