推荐使用的三个头文件

#include<opencv2\core\core.hpp>
#include<opencv2\imgproc\imgproc.hpp>
#include<opencv2\highgui\highgui.hpp>

core 核心功能,基本的数据结构和算法函数

imgproc 图像处理函数

highgui 图像,视频读写和界面函数

Mat image;//创立空图像
std::cout << image.rows << " " << image.cols << std::endl;//显示尺寸
image=imread("img/oneimg.jpg");
    if (image.empty()) {
        //错误处理
        std::cout << "Wrong answer" << std::endl;
    }

注意imread使用方式,不能用 \

//定义窗口(可选)
namedWindow("Image");
//显示图像
imshow("Image", image);
waitKey(0);//0表示永远等待按键,正数表示等待指定的毫秒数

然后就可以打开图片了

                                                                         Opencv学习(一)

Mat result;
flip(image, result, 1);//翻转,1水平,0垂直,负数水平垂直
imshow("Out img", result);
imwrite("out.jpg", result);//保存结果

 

相关文章:

  • 2021-10-01
  • 2021-12-31
  • 2021-08-11
  • 2021-11-14
  • 2022-01-23
  • 2022-02-06
  • 2021-11-12
猜你喜欢
  • 2021-04-08
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
相关资源
相似解决方案