Installing & Configuring OpenCV 2.1 with Visual Studio 2010


Latest tutorial on how to install & configure OpenCV 3.3.1 with Visual Studio 2015 can be found here.


Installation
You can download the latest OpenCV library from its sourceforge.net page. But for Windows 7, Windows Vista or Windows XP SP3 users, it is easy to download Latest OpenCV Windows executable (.exe) file and just double click it to install. 
Once you have completed installing, you need to change some settings in your IDE so that it knows where to find the library files and header files of OpenCV. I’ll demonstrate the configuring process of  Microsoft Visual Studio 2010. (The configuration process is same for  Microsoft Visual C++ 2010 Express Edition (free))


Steps to Configure Microsoft Visual Studio 2010
  • Start Microsoft Visual Studio 2010
  • Go to File>New>Project>Visual C++>Win32>Win32 Console Application. Enter a name, say "HelloWorld" for your application and then click OK


Creating Visual C++ Application
  • In Visual Studio 2008
    • Go to 'Tools > Options > Projects and Solutions'
  • In Visual Studio 2010
    • Go to 'Project > Properties'  or  'Project > Helloworld Properties'  
  • Don't forget to select Configurations as 'All Configurations' as illustrated below
  • In the left pane, click  'Configuration Properties>VC++ Directories'
    • In Include Directories, add 'C:\OpenCV2.1\include\opencv'
    • In Library Directories, add 'C:\OpenCV2.1\lib'
    • In Source Directories, add 'C:\OpenCV2.1\src\cv; C:\OpenCV2.1\src\cvaux; C:\OpenCV2.1\src\cxcore; C:\OpenCV2.1\src\highgui; C:\OpenCV2.1\src\ml'
Configuring Microsoft Visual Studio for OpenCV
  • In the left pane, Click  'Configuration Properties > Linker > Input'
    • In Additional Dependencies, add 'cv210.lib; cxcore210.lib; highgui210.lib; cvaux210.lib; ml210.lib '
Configuring Microsoft Visual Studio for OpenCV


Now you are ready to write your first computer vision program using the 'OpenCV' library with Visual C++.



Next Lesson : OpenCV C++ API