Ask Your Question

Error while installing opencv in visual studio 2012

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

x555x gravatar image

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

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
int main()
          IplImage* img = cvLoadImage("C:/Users/Shyama Panolth/Pictures/Images/Hardeep Singh.jpg");
          cvShowImage("MyWindow", img);
          return 0;

Please help

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

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

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); 
    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


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

Seen: 568 times

Last updated: Apr 26 '13