Getting Started with OpenCV

Finally our final year project is finished. As I've promised in my previous post I'm going to do few posts on OpenCV. In this post I'm going to tell you how to configure MS Visual Studio 2005 to work with OpenCV library. 

Step 1: Installiny OpenCV

First you have to download the OpenCV library from Sourceforge and run the installer. It will install OpenCV library on your computer. By default it will be installed to "C:\Program Files\OpenCV". Installer will add "C:\Program Files\OpenCV\bin" to system's PATH variable. But sometimes this do not happen properly. In such cases you'll have to add OpenCV bin directory manually to the system's PATH.

OpenCV installer

Download OpenCV: http://sourceforge.net/projects/opencvlibrary/

Step 2: Configuring VS 2005

In order to use OpenCv from VS you have to add libraries and header files to projects path. Create Win32 Console Application in VS 2005. Then right click the project form the Solution Explorer and select Properties.

project properties

Under "Configuration Properties -> C/C++ -> General" put following folders to "Additional Include Directories".

C:\Program Files\OpenCV\cxcore\include
C:\Program Files\OpenCV\cv\include\
C:\Program Files\OpenCV\cvaux\include
C:\Program Files\OpenCV\otherlibs\highgui

set include directories

Then under "Configuration Properties -> Linker -> Input" put following folders to "Additional Dependencies". Add them line by line with double quotes.

"C:\Program Files\OpenCV\lib\cv.lib"
"C:\Program Files\OpenCV\lib\cvaux.lib"
"C:\Program Files\OpenCV\lib\cxcore.lib"
"C:\Program Files\OpenCV\lib\highgui.lib"

set linker dependancies

Sometimes it is possible that you don't have above lib files in "C:\Program Files\OpenCV\lib" folder. In such situations you just have to compile the OpenCV solution.

It is also possible for you to get complains regarding corex100.dll (it can be corexXXX.dll) when running your OpenCV application. If you get such error build the OpenCV solution and check whether the "C:\Program Files\OpenCV\bin" folder is in your system PATH, if not you either have to add that to the path or copy all the DLLs in bin folder to C:\WINDOWS\SYSTEM32 folder.

opencv solution

So that basically what you have to do to configure VS2005. You can check whether you have configured the VS correctly by compiling and running some sample applications in the "C:\Program Files\OpenCV\samples\c" folder. So have fun with OpenCV.

 

Reader Comments

hi that was really helpful
by the way have u tried to configure opencv with dev c++ because i am facing some problems with it i.e. whenever i run sample programs they run but if i make new program it gives msg that source not compiled even if new program is the copy of sample program
pls help me its urgent

Thank you, thank you, thank you. I've spent the last 3 hours trying to figure out how to get round the dll error (which confused me because the environment variable seemed ok).