# Issue with cv2.PerspectiveTransform and Direct Point Specific Homography Translation [Python]

I am attempting to use the perspectiveTransform() function for tranlation of cordinates using homography matrix.

I used the following method to input homography matrix along with the coordinates. This function returns a list of a list of the number of points, each of size 512. A list consisting of 4 lists of size 512 in the current scenario. I was expecting to get four updated coordinates.

    points=np.array([[xmin,ymin],[xmin,ymax],[xmax,ymin],[xmax,ymax]], dtype='float32')
h=np.array([homographyMatrix],dtype='float32')
print(cv2.perspectiveTransform(cords,h))


Moreover, I found another solution earlier regarding the translating of a single coordinate using the homography matrix directly and extending the dimensional (x,y,1) and using the third dimension to normalize the new coordinates will give me the translated coordinates. But this gives me one negative and a positive incorrect coordinate

p1=(x1, y1, 1)
p2=p1.dot(H)   #numpy matrix multiplication function
p2 /= p2[2]; //normalize the output to get the right (x2, y2, 1)


I want the updated coordinates of the player after transformation for a single point (x,y) I want to know at what position (x',y') will it be translated to

edit retag close merge delete