OpenCV加载图像并显示
从文件中读取一直一张图片,并加载出来
代码:
#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; }
结果展示: