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

OpenCV加载图像并显示

时间:2015-11-21 13:12:36      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

从文件中读取一直一张图片,并加载出来

代码:

#include "stdafx.h"
#include "iostream"
using namespace std;
#include "opencv2/opencv.hpp"

int main()
{
    const char *pImagePath = "E:/C_VC_code/Text_Photo/girl001.jpg";
    const char *pWindowsTitle = "MyFirst OpenCV";

    //load image from file
    IplImage *pImage = cvLoadImage(pImagePath,CV_LOAD_IMAGE_UNCHANGED);

    //create window
    cvNamedWindow(pWindowsTitle,CV_WINDOW_AUTOSIZE);

    //show image on window
    cvShowImage(pWindowsTitle,pImage);

    //wait key event
    cvWaitKey(0);

    cvDestroyWindow(pWindowsTitle);
    cvReleaseImage(&pImage);
    return 0;
}

结果展示:

技术分享

OpenCV加载图像并显示

标签:

原文地址:http://www.cnblogs.com/mypsq/p/4983267.html

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