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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM