#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
Mat tag;
Mat tagdst = Mat::zeros(tag.cols, tag.rows, tag.type());
tag = imread("E://VS-pro//images//flower.bmp");
imshow("原图", tag);
Point2f srcTr[3];
Point2f dstTr[3];
srcTr[0] = Point(tag.cols / 4, tag.cols / 4);
srcTr[1] = Point(tag.cols - 1, 0);
srcTr[2] = Point(0, tag.rows - 1);
dstTr[0] = Point(tag.cols / 4, tag.cols / 4);
dstTr[1] = Point(tag.cols - 1, 0);
dstTr[2] = Point(0, tag.rows / 2);
Mat warpMat = getAffineTransform(srcTr, dstTr);
warpAffine(tag, tagdst, warpMat, tagdst.size());
imshow("变换后", tagdst);
waitKey(0);
return 0;
}

不同参数
Point2f srcTr[3];
Point2f dstTr[3];
srcTr[0] = Point(0, 0);
srcTr[1] = Point(tag.cols - 1, 0);
srcTr[2] =

本文探讨了在OpenCV中如何进行仿射变换,特别是图像的旋转操作。通过getRotationMatrix2D函数计算旋转和缩放矩阵,实现了图像约45°的旋转。同时,文章提出了如何确保旋转后的图像能完整显示的问题,并暗示将在毕业后分享更多相关内容。
最低0.47元/天 解锁文章
240

被折叠的 条评论
为什么被折叠?



