Ask Your Question
0

Error while installing opencv in visual studio 2012

asked 2013-04-26 06:28:44 -0600

x555x gravatar image

updated 2013-04-26 07:30:16 -0600

Hi everyone, Im new to opencv and am trying to install it in visual studio 2012. Im getting the following error while building the code :

error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

The code I used is :

#include "stdafx.h"
#include cv.h
#include highgui.h
#define _CRT_SECURE_NO_WARNINGS
int main()
{
          IplImage* img = cvLoadImage("C:/Users/Shyama Panolth/Pictures/Images/Hardeep Singh.jpg");
          cvNamedWindow("MyWindow");
          cvShowImage("MyWindow", img);
          cvWaitKey(0);
          cvDestroyWindow("MyWindow");
          cvReleaseImage(&img);
          return 0;
}

Please help

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-04-26 07:34:47 -0600

Which version of OpenCV are you using? Try using the latest openCV stable version 2.4.5 and use the C++ style API.

#include "stdafx.h"
#include "opencv/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"

int main()
{
    Mat img = imread("C:/Users/Shyama Panolth/Pictures/Images/Hardeep Singh.jpg");
    imshow("MyWindow", img); 
    waitKey(0);
    return 0;
}

This works in VS2012 for me with the same error a simple warning. It is depricated code but you should still be able to use it.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-04-26 06:28:44 -0600

Seen: 655 times

Last updated: Apr 26 '13