Вы находитесь на странице: 1из 5

OpenCV with Visual C++ 6.

0, 2005 Express, and 2008 Express

The set of instructions below is tested with Visual C++ 2003. It will also work with some modification under Visual C++ 6.0 and Visual C++ 2005, 2008
Express Edition.

To create your own OpenCV-based project in Visual Studio do the following:

Linking DLLs:

 To permanatly 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.
 It might be required to restart Visual C++ when execution of instance failes after successful build.

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\cvcam\include"

http://opencvlibrary.sourceforge.net/VisualC%2B%2B?action=print
 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\cvcam\src\windows"

 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.

http://opencvlibrary.sourceforge.net/VisualC%2B%2B?action=print
 Type the project name and choose location
 Click Ok.. In the Application Wizard, Just click Finish.

After the above steps done Developer Studio will create the project folder (by default it has the same name as the project), <project name>.vcproj file,
Solution <project name>.sln and, Three Source files: <project name>.cpp, stdafx.cpp and stdafx.h. StdAfx files are precompiled header files, which
can be very useful if you want to reduce the compilation time.
 For example, consider that we have created a new "Hello" Project. Open the Hello.cpp file, and include the OpenCV-related #include directives:

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

Note that these should be included after stdafx.h or you may get build errors.
Now Type some OpenCV code, and Build the Solution by pressing the F7 Key. There should be linker errors.
 Add dependency projects into workspace
 Choose from menu: "Project" -> "Properties".
 Choose "Linker" tab -> "Input" category -> "Additional Dependencies:". Add the paths to all neccessary import libraries (cxcore[d].lib cv[d].lib highgui
[d].lib cvaux[d].lib cvcam[d].lib)
Note: The debug versions are available only when you Build the Visual C++ .NET solution provided with the OpenCV installation.

http://opencvlibrary.sourceforge.net/VisualC%2B%2B?action=print
If the build process complains about a missing 'windows.h' header file, then you'll need to install the latest version of the Microsoft Windows SDK.
. Thats it!.. Now Build and Run the application using F5 key and enjoy OpenCV!

If you have any queries regarding this, try posting at OpenCV Yahoo! Groups.

http://opencvlibrary.sourceforge.net/VisualC%2B%2B?action=print
.

All the Best!


Paramesh.
Modified by Seongjoo 2008-06-13

VisualC++ (last edited 2008-06-13 05:18:51 by Lee Seongjoo)

http://opencvlibrary.sourceforge.net/VisualC%2B%2B?action=print

Вам также может понравиться