OpenCV getRotationMatrix2D 函数

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[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;
}

\(x=x*\cos\theta+y*\sin\theta+(1-\cos\theta)*center_x-\sin\theta*center_y\)
\(y=-\sin\theta*x+y*\cos\theta+\sin\theta*center_x+(1-\cos\theta)*center_y\)

posted on 2020-08-11 15:12  庭中核桃树  阅读(654)  评论(0编辑  收藏  举报

导航