The first thing to do is get OpenCV. You can download it from its sourceforge.net page. Make sure you download the latest version and the correct one for your platform.
Update: OpenCV 2.0 is now available. This post works for OpenCV 1.0. Check how to install OpenCV 2.0.
Once you're done installing, you need to change some settings in your IDE so that it knows where to find the header files and the library files for OpenCV.
I'll demonstrate the process with these IDEs: Microsoft Visual Studio 2008 and Microsoft Visual Studio 6.
Other websites mention how to use OpenCV with other environments:
Start Visual Studio 2008 and goto Tools > Options.
In the Options, goto Projects and Solutions > VC++ Directories.
On this page, there is a drop down list called Show directories for. It has six options: Executable files, Include files, Reference files, Library files, Source files and Exclude directories. We're interested in the Include files and Library files.
Select the Include files option, and setup the options as shown below:
Note: On my computer, I installed OpenCV in the D:\\Program Files\\OpenCV directory. You might have installed it at some different location, so make sure you change the paths appropriately.
Now change the Show directories _for to _Library files. All the library files of OpenCV are located in just one directory, so simply add that directory:
Note: Again, make sure you use the appropriate the directory path.
You're done! Now your Visual Studio 6 knows where to find OpenCV!
Start Visual Studio 6.0 and goto Tools > Options.
In the Options dialog box, go to the _Directories _tab.
On this tab, there is a drop down list called Show directories for. It has four options: Executable files, Include files, Library files and Source files. We're interested in the Include files and Library files.
Select the Include files option, and setup the options as shown below:
Note: On my computer, I installed OpenCV in the D:\\Program Files\\OpenCV directory. You might have installed it at some different location, so make sure you change the paths appropriately.
Now change the Show directories for to Library files. All the library files of OpenCV are located in just one directory, so simply add that directory:
Note: Again, make sure you use the appropriate the directory path.
You're done! Now your Visual Studio 6 knows where to find OpenCV!
Now that your IDE knows exactly where OpenCV is, you can make OpenCV applications. To use OpenCV, you need to specify that you want to use OpenCV libraries.
You need to modify your project's settings in order to do that. I'll demonstrate how to do that in the next tutorial.
This post is a part of an article series on OpenCV for Beginners
Here's a simple task - given an image find the dominant colors in the image. I'll walk you through a lesser known technique that does not use kmeans.
Read more