#include <stdio.h>
#include <iostream>
#include <string>
#include <opencv2\opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat img = imread("person1.jpeg");
Point2f src[3]= { Point2f(0,0),Point2f(0,img.cols-1),Point2f(img.rows-1,img.cols-1) };
Point2f dst[3] = { Point2f(img.rows*0.11,img.cols*0.2),Point2f(img.rows*0.15,img.cols*0.7),Point2f(img.rows*0.81,img.cols*0.85) };
Mat rotation1, img_dst1;
rotation1 = getAffineTransform(src, dst);
warpAffine(img, img_dst1, rotation1, Size(img.cols,img.rows));
namedWindow("仿射变换", WINDOW_NORMAL);
imshow("仿射变换", img_dst1);
double angle = 30;
Point2f center(img.rows / 2, img.cols / 2);
Mat rotation2, img_dst2;
rotation2 = getRotationMatrix2D(center, angle, 1);
namedWindow("旋转变换", WINDOW_NORMAL);
warpAffine(img, img_dst2, rotation2, Size(img.cols,img.rows));
imshow("旋转变换", img_dst2);
waitKey(0);
return 0;
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/b6ac83922d9f47d48d7b9f4c8620b230.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBARiBsIGU=,size_20,color_FFFFFF,t_70,g_se,x_16)