码迷,mamicode.com
首页 > 其他好文 > 详细

opencv图片旋转90度

时间:2019-09-19 14:13:36      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:opencv   show   write   int   bsp   图片旋转   pen   mamicode   double   

 

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

技术图片

 

opencv图片旋转90度

标签:opencv   show   write   int   bsp   图片旋转   pen   mamicode   double   

原文地址:https://www.cnblogs.com/herd/p/11548786.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!