Skip to content

samgooi4189/openCVforBeginners_Win

Repository files navigation

openCVforBeginners_Win

OpenCV2.4 for Visual Studio 2010

Grab the source code

  • Download opencv.

  • Extract opencv to C:\

Building the binaries

  • 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.

Setting up the hello world project

  • Create a new project in VS.
  • Choose console application and leave precompiled headers ticked.
  • Right-click on solution file and choose properties.

In the VC++ Directories window, add the following:

Include Directories: C:\opencv\build\include;C:\opencv\build\include\opencv;C:\opencv\build\include\opencv2
Library Directories: C:\opencv\lib\Debug
Source Directories: C:\opencv\build\include

In C++ -> Linker -> Input, add the following to Additional Dependencies:

<include all the .lib in opencv/lib/debug>
opencv_core242d.lib
opencv_highgui242d.lib
......

Lets start editing Hello World Content

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.

Missing opencv_core242d.dll?

Go to Properties under My Computer >> Advanced System Settings >> Environment Variables >>
Add "C:\opencv\bin\Debug" to path
Restart your PC
run your executable

About

OpenCV2.4 for Visual Studio 2010

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published