Friday, October 30, 2009

Linking and configuring OpenCV with Visual C++ .Net

In my eailer posts I have written how to Link Opencv Library in VC++ visula studio 6 and in Bloodshed's DEVC++. Now we will learn how to Link and configue OpenCV with Visual C++ .Net.

Linking DLLs:

•    To permanantly include necessary dll files, add "C:\Program Files\OpenCV\bin" to PATH by visiting Advanced tab in System of Windows (the locate of directory might be different).
•    One can just copy necessary dll files into project directory with source files.

Customize Global Options:
•    Open the Visual C++ .Net Application. In the menu bar, select Tools->Options
•    In the listing, choose Projects->VC++ Directories.
•    First, select Library files from the "Show Directories for" List Box.
•    Click the Insert New icon, and locate the folder where you have installed opencv.
•    Consider that it is installed in "C:/Program Files/OpenCV".
•    In the Library files list, locate and add:
"C:\Program Files\OpenCV\lib"


•    Now choose Include files in the list box, and locate and add the following directories:
        "C:\Program Files\OpenCV\cv\include"
        "C:\Program Files\OpenCV\cxcore\include"
        "C:\Program Files\OpenCV\otherlibs\highgui"
        "C:\Program Files\OpenCV\cvaux\include"
        "C:\Program Files\OpenCV\otherlibs\_graphics\include



  • Next, choose source files in the list box, and locate and add the following directories:
        "C:\Program Files\OpenCV\cv\src"
        "C:\Program Files\OpenCV\cxcore\src"
        "C:\Program Files\OpenCV\cvaux\src"
        "C:\Program Files\OpenCV\otherlibs\highgui"
        "C:\Program Files\OpenCV\otherlibs\_graphics\src"

Now click OK in the Options dialog.
•    You have successfully configured the global settings.
Create New Project:
•    Within Developer Studio create new application:
•    Select from menu "File"->"New..."->"Projects" tab.
•    Choose "Win32 Application" or "Win32 console application" - the latter is the easier variant and both the sample projects have this type.



Type the project name and choose location
•    Click Ok.. In the Application Wizard, Just click Finish. 

1 comment: