简体   繁体   中英

How to rotate an image by remap

For a specific purpose I am trying to use Open CV's remap function to rotate an image by a specific angle (angle can be changed while using the function).

I have checked the open cv's documentation and example page and have come so far as to being able to rotate the image by let's say 180 degrees. The problem I still have is the angles in between.

for (int x = 0; x < src.cols; x++)
{
    for (int y = 0; x < src.rows; y++)
    {
        map_x.at<float>(y, x) = (float)(src.cols - x);
        map_y.at<float>(y, x) = (float)(src.rows - y);
    }
}

This sample code is for rotating 180 degrees.

My question again is, how achieve the rotation for any wanted angle.

OpenCV already HAS this function:

Mat getRotationMatrix2D(Point2f center, double angle, double scale)

you can read more at: opencv docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM