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

asked 2019-12-25 08:27:58 -0600

muaz65 gravatar image

updated 2019-12-25 10:51:23 -0600

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 flag offensive close merge delete

Comments

your points array repeats the last coord

(should probably be [xmax,ymin])

berak gravatar imageberak ( 2019-12-25 09:44:11 -0600 )edit

yes but that still doesn't solve my problem

muaz65 gravatar imagemuaz65 ( 2019-12-25 10:01:25 -0600 )edit