Hi Guys. In this post I explain:
- Configuring OpenCV 2.1 on Visual Studio 2008.
- A sample OpenCV 2.1 program to run on Visual Studio.
Click here for Configuring OpenCV 2.2 on Linux
Btw, My other programs in OpenCV will be posted here.
I see lot of you facing problems in configuring OpenCV 2.1 for Visual Studio on Windows OS. In this post I seek to explain the way it is to be configured.
Step1: Download
Download OpenCV from http://sourceforge.net/projects/opencvlibrary/
Present version is 2.2, but I show here working with OpenCV 2.1 (configuring OpenCV 2.2 will be the same if you follow this procedure).
Step2: Install OpenCV
Double click to install the downloaded file. I am sure nobody needs help on this. It usually is installed in C:\ as "C:\OpenCV2.1"
Steps 3 to 14: Configure OpenCV with Visual Studio 2008
Step3: Open Visual Studio 2008. I am assuming you have already installed Visual Studio with VIsual C++ editor. Select New->Project
Step4: Give the name of the project, the name i've given is "OpenCam". Make sure that it is a "Win32 Console Application" program.
Step5: Right click on the Project in Solution Explorer and select properties.
Step6: Now we configure the Visual Studio to include the headers that come with OpenCV 2.1. Go to Configuration Properties->C/C++->General->Additional Include Directories and select to add new directories.
Step 7: Open the OpenCV installation directory, browse through the folders "C:\OpenCV2.1\include\opencv" and copy the address to the path. Basically, what we are doing here is to browse into the OpenCV C/C++ headers folder (look for ".h" files). Paste it into the Visual Studio window already opened (into additional include directories).
It will look something as show below. Press OK.
Step8: Now we configure the Visual Studio to look for libraries installed (OpenCV libraries).Go to Linker->input->Additional Dependencies and click to add new libraries.
Step 9: Open the OpenCV installation directory, browse through the folders "C:\OpenCV2.1\lib" and copy the address to the path. Basically, what we are doing here is to browse into the OpenCV C/C++ libraries folder (look for ".lib" files). Paste it into the Visual Studio window already opened (into additional dependencies).
Step 10: Add the libraries "cv210.lib", "cvaux210.lib", "cxcore210.lib", "highgui210.lib" into the additional dependencies.Please make sure that you give complete path to the above mentioned ".lib" files.
It SHOULD look something as below.
Step 11: Press OK. If you do not have a program of your own to run by copying the following, else proceed to Step 12.
Step 12: Now its time to build the solution. Go to Build->Build Solution.
Step 13: If everything is right (it will be if you are following the exact steps that I'm following here) something like this should show up in the output window.
Step 14: Now its time to run the program. Click on run and BING! Its there. You should be able to see yourselves (if you are running the program and assuming you have a webcam of your own attached to your computer).
Basically what we've done is give
"exact path" to the
include directories folder and
"excat path" to the
".lib" files that are to be included to run the program and it works.
Cheers. Check out the
other OpenCV articles over here.