#include "stdafx.h"
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{
//read image c style
IplImage *img = cvLoadImage("......lena.jpg");
if (!img) {
cout << "cannot open the file" << endl;
cvReleaseImage(%img);
exit(-1);
}
cvNamedWindow("Test", CV_WINDOW_AUTOSIZE);
cvShowImage("Test", img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Test");
/************************************************************************************************/
//read image cpp style
string imagename = "......lena.jpg";
//read image
Mat img = imread(imagename);
//cannot open the file
if(img.empty())
{
return -1;
}
//create a window
namedWindow("image",1);
//show the window
imshow("image", img);
waitKey();
return 0;
}