OpenCV2.4 for Visual Studio 2010
-
Download opencv.
-
Extract opencv to C:\
-
Download cmake. Open the cmake gui..
-
Where is the source code: C:/opencv
-
Where to build the binaries: C:/opencv/build
-
Click Configure - for the generator choose Visual Studio 10 Click Generate.
-
In C:\opencv\build you should now see OpenCV.sln.
-
Open the solution file with Visual Studio 2010 or C++ Express and build it.
- Create a new project in VS.
- Choose console application and leave precompiled headers ticked.
- Right-click on solution file and choose properties.
Library Directories: C:\opencv\lib\Debug
Source Directories: C:\opencv\build\include
<include all the .lib in opencv/lib/debug>
opencv_core242d.lib
opencv_highgui242d.lib
......
Change the helloworld.cpp in source:
#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
int _tmain(int argc, _TCHAR* argv[])
{
IplImage *img = cvLoadImage("funny-pictures-cat-goes-pew.jpg");
cvNamedWindow("Image:",1);
cvShowImage("image:",img);
cvWaitKey();
cvDestroyWindow("Image:");
cvReleaseImage(&img);
return 0;
}
Place the image (or any image) in your project directory.
Now build and hit Debug, and it should work. Hope this helps someone.
Add "C:\opencv\bin\Debug" to path
Restart your PC
run your executable