I have matrix that is used for rotation:
CvMat* rot_mat = cvCreateMat(2, 3, CV_32FC1);
cv2DRotationMatrix(center, angle, scale, rot_mat);
...
This matrix is used for image operations.
cvWarpAffine(..., ..., rot_mat, ..., ...);
I have to know, how this matrix should affect exact pixel - location it should be transfered.
How can I multiply 2D point (pixel location) and my matrix to find out where pixel should be transferred?
I found an answer to this in this forum. Just in case the link fails here is the solution:
cv::Point2f operator*(cv::Mat M, const cv::Point2f& p)
{
cv::Mat_<double> src(3/*rows*/,1 /* cols */);
src(0,0)=p.x;
src(1,0)=p.y;
src(2,0)=1.0;
cv::Mat_<double> dst = M*src; //USE MATRIX ALGEBRA
return cv::Point2f(dst(0,0),dst(1,0));
}
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