display image prob ?
I’ve try to create a C++ program using OpenCV to open an image in my laptop, but it doesn’t work ! Here is my code:
#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
int _tmain(int argc, _TCHAR* argv[])
{
IplImage* img =cvLoadImage("D:\Pictures\love.jpg");
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvShowImage( "Example1", img );
cvWaitKey();
cvReleaseImage(&img );
cvDestroyWindow( "Example1" );
return 0;
}
After build & debug, a window popped up but had no image on it. And there are some warnings ad follow:
Warning 3 warning C4129: 'l' : unrecognized character escape sequence d:\document\study\university of technology\semester_8\computer vision\c++ projects\30-1 at home\30-1 at home\30-1 at home.cpp 11 1 30-1 at home
Warning 2 warning C4129: 'P' : unrecognized character escape sequence d:\document\study\university of technology\semester_8\computer vision\c++ projects\30-1 at home\30-1 at home\30-1 at home.cpp 11 1 30-1 at home
Warning 1 warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. c:\opencv2.2\include\opencv2\flann\logger.h 66 1 30-1 at home
I hope someone can help me solve this problem! Thanks !
[EDIT 1} here is my code after being changed:
#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
int _tmain(int argc, _TCHAR* argv[])
{
IplImage* img =cvLoadImage("D:/Pictures/love.jpg",CV_LOAD_IMAGE_UNCHANGED);
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvShowImage( "Example1", img );
cvWaitKey();
cvReleaseImage(&img );
cvDestroyWindow( "Example1" );
return 0;
}
but that warning still occured !