Ask Your Question

sjm's profile - activity

2013-10-21 05:03:33 -0600 answered a question OpenCV cv2 perspective transformation matrix multiplication

You cannot multiply a 3x3 matrix. You must make the matrix 4x4:

[x,x,x,0]

[x,x,x,0]

[x,x,x,0]

[0,0,0,1]

you then multiply and then set back to a 3x3 matrix. Watch out for numpy's format for selecting the individual parts, use m.item. Don't use np.resize, it messes the matrix up.

2013-10-18 22:25:15 -0600 received badge  Editor (source)
2013-10-18 22:24:44 -0600 asked a question OpenCV cv2 perspective transformation matrix multiplication

I am trying to combine a series of warpPerspective into one by combining the matrices generated by getPerspectiveTransform. If I multiply them together using cv2.multiply the resulting matrix doesn’t work. Example for just two transformations:

src = np.array([[0,0],[0,480],[640,480],[640,0]],np.float32)

dst = np.array([[-97,-718],[230,472],[421,472],[927,-717]],np.float32)

retval = cv2.getPerspectiveTransform(src, dst);

test = cv2.multiply(retval.copy(),retval.copy())

img1 = cv2.warpPerspective(img1,test,(640,480))

img2 = cv2.warpPerspective(img2,retval,(640,480))

img2 = cv2.warpPerspective(img2,retval,(640,480))

Why aren't img1 and img2 the same? How do I combine the perspective transformation matrices?

Thanks