I am using cv2.getRotationMatrix2D to get a 2x3 matrix to rotate a source image. This works fine. Now i have several 2D coordinates, which represent points in the unrotated image.
Can I use the same matrix to rotate the indiviual points and if yes, how?
If i understood correcty, I should be able to multiply the matrix with the (x,y)-coordinates, but no matter which combination of matrix and points I try, I never get simple x and y coordinates as a result.
Thanks for your help!
Edit:
the rotation matrix is
[[ 9.24630834e-01 3.80864571e-01 1.52747702e-01]
[ -3.80864571e-01 9.24630834e-01 1.57068951e+02]]
What I am doing so far:
point = np.array([marker.x, marker.y, 1])
transform = rot_matrix * point.T
print transform
But this does not give me a 2x1 matrix as it should, but:
[[ 2.10815830e+02 7.92198307e+01 1.52747702e-01]
[ -8.68371221e+01 1.92323213e+02 1.57068951e+02]]
Please check this site. As cv2.getRotationMatrix2D creates a affine transformation, you can write the result of the call like this:
.
If you now want to transform a 2D point you have to calculate this expression


This should solve your issue. (All images come from the referenced documentation page)
Edit: Regarding your edit: You cannot use the * operator, but should maybe use np.dot(). The * operator is only performing a real matrix-vector product for matrix object. Otherwise, it is performing a element-wise product.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With