//Rotation angle in degrees.
//Positive values mean counter-clockwise rotation
//(thecoordinate origin is assumed to be the top-left corner).
cv::Mat cv::getRotationMatrix2D( Point2f center, double angle, double scale )
{
CV_INSTRUMENT_REGION();
angle *= CV_PI/180;
double alpha = std::cos(angle)*scale;
double beta = std::sin(angle)*scale;
Mat M(2, 3, CV_64F);
double* m = M.ptr<double>();
//获取矩阵M的底层数据指针,用于直接访问矩阵元素。
m[0] = alpha;
m[1] = beta;
m[2] = (1-alpha)*center.x - beta*center.y;
m[3] = -beta;
m[4] = alpha;
m[5] = beta*center.x + (1-alpha)*center.y;
return M;
}
顺时针为正,左上角为默认坐标原点
CV_INSTRUMENT_REGION()
是一个OpenCV宏,用于在代码中进行性能分析和测量。它可以用于标记代码的某个区域,以便在运行时获取该区域的性能指标。(不太明白,先放一下)
?