opencv图片旋转90度
#include<iostream> #include <opencv2/opencv.hpp> using namespace std; using namespace cv; int test1() { Mat img1, img2,img3; img2 = cv::Mat(640, 480,CV_8UC3); img1 = imread("D://images//opencv测试图片//190.jpg"); if (img1.empty()) { return -1; } int width1 = img1.rows; int height1 = img1.cols; std::cout << "w:" << width1 << " h1:" << height1<<std::endl; double angle = 90.0; //角度 double scale = 1.0; //缩放系数 cv::transpose(img1, img2); cv::flip(img2, img2, 1); int width2 = img2.rows; int height2 = img2.cols; std::cout << "w:" << width2 << " h1:" << height2 << std::endl; imshow("win1", img1); imshow("win2", img2); imwrite("D://images//opencv测试图片//img2019091902.jpg", img2); return 0; } int main() { test1(); waitKey(0); return 0; }
QQ 3087438119