Opencv C++成长之路(二):图像的读取与显示

版权声明:——转载请留言询问—— https://blog.csdn.net/weixin_44344462/article/details/88721267

效果

在这里插入图片描述

Show me the code

#include <iostream>
#include <string>
#include <opencv2/highgui.hpp>

using namespace std;

int main() {
    // 文件路径
    const string filePath = "xxx.jpg";
    
    // 读取图像存入origin
    cv::Mat origin = cv::imread(filePath);

    // 创建一个窗口
    cv::namedWindow("Origin Image");

    // 在名为“Origin Image”的窗口显示图像
    cv::imshow("Origin Image", origin);

    // 用c接收键盘按键的映射
    int c = cv::waitKey(0);

    // 如果按下Esc则销毁所有窗口
    if (c == 27) {
        cv::destroyAllWindows();
    }
    
}

猜你喜欢

转载自blog.csdn.net/weixin_44344462/article/details/88721267
今日推荐