Reputation: 13
I am using python opencv version 4.5.
import cv2
import numpy as np
rigidRect = np.float32([[50,-50],[50,50],[-50,50]])
shiftRect = np.float32([[50,-30],[50,70],[-50,70]])
M = cv2.getAffineTransform(rigidRect, shiftRect) #this return [[1,0,0],[0,1,20]]
validateRect = cv2.warpAffine(rigidRect, M, (2,3))
and validateRect
return a 3 by 2 zeroes matrix.
I thought validateRect
will equal to shiftRect
?
Upvotes: 1
Views: 563
Reputation: 2495
warpAffine
is used to transform an image using the affine transform matrix. What you are trying to do is to transform the given points, which is achieved by the transform
function. Documentation of getAffineTransform
gives hint about related functions in see also part.
validateRect = cv2.transform(rigidRect[None,:,:], M)
Upvotes: 2