I’m having troubles with rotation. What I want to do is this:
If M
is the rotation matrix you get from cv::getRotationMatrix2D
, to rotate a cv::Point p
with this matrix you can do this:
cv::Point result;
result.x = M.at(0,0)*p.x + M.at(0,1)*p.y + M.at(0,2);
result.y = M.at(1,0)*p.x + M.at(1,1)*p.y + M.at(1,2);
If you want to rotate a point back, generate the inverse matrix of M
or use cv::getRotationMatrix2D(center, -rotateAngle, scale)
to generate a matrix for reverse rotation.