OpenCV简单示例

 // Demo.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "highgui.h" #include "cv.h" #include "cxcore.h" #pragma comment(lib, "cxcore200d.lib") #pragma comment(lib, "cv200d.lib") #pragma comment(lib, "highgui200d.lib") int _tmain(int argc, _TCHAR* argv[]) { //1. /*const char* strName = "demo.jpg"; cv::Mat img = cv::imread(strName); if (img.empty()) { printf("Can not open image file/n"); return 0; } if (!img.data) { return 0; } cvNamedWindow("image", CV_WINDOW_AUTOSIZE); cv::imshow("image", img); cv::waitKey();*/ //2. /*IplImage* pImg; pImg = cvLoadImage("demo.png", 0); if (!pImg) { return -1; } cvNamedWindow("Image", 1); cvShowImage("Image", pImg); cvWaitKey(0); cvDestroyWindow("Image"); cvReleaseImage(&pImg);*/ //3. IplImage* pImg; if(!(pImg = cvLoadImage("demo.png", 0))) return -1; IplImage* pImg2 = cvCreateImage(cvGetSize(pImg), pImg->depth, pImg->nChannels); cvCopy(pImg, pImg2, NULL); cvSaveImage("demo2.png", pImg2); cvNamedWindow("Image", 1); cvShowImage("Image", pImg); cvWaitKey(0); cvDestroyWindow("Image"); cvReleaseImage(&pImg); return 0; }

你可能感兴趣的:(image,null)