You are on page 1of 10


10 / jakub czaplicki / twitter:kupsztal

OpenCV under Microsoft Visual C++ 2008 Express Edition (WinXP)

This is a small walkthrough which I put together while I tried to run OpenCV using
MS Visual C++ 2008 Express Edition. This document is mainly based on and

1. Download & install OpenCV for Windows - OpenCV_1.0.exe from (In this small tutorial OpenCV has been
installed into C:/Program Files/OpenCV/ )

2. Download & install Microsoft Visual C++ 2008 Express Edition WinXP or later)

3. Register it (
Help->Register Product.)
a. You will receive email with link to confirm your email address
b. Then you will receive another email with link to the registration

4. Once you have your VC++ registered and it's ready to use, you need to
customize Global Options so that you can use OpenCV libraries.

• In the menu bar, select Tools->Options

• In the listing, choose Projects and Solutions->VC++ Directories.

• First, from the "Show Directories for:" list box choose "Include Files".
(“Platform” list box should show “Win32”), see screenshot
• Click the Insert New icon, and locate the folder where you have installed
OpenCV. Let’s consider that it is installed in "C:\Program Files\OpenCV\"

• In the "Include files" list, locate and add:

"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"
"C:\Program Files\OpenCV\ml\include"
"C:\Program Files\OpenCV\otherlibs\_graphics\include"
"C:\Program Files\OpenCV\otherlibs\_graphics\include\jasper"
• Next, choose "Library files" in the list box, and locate and add the
following directories:
"C:\Program Files\OpenCV\lib"
"C:\Program Files\OpenCV\otherlibs\_graphics\lib"

• 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"
"C:\Program Files\OpenCV\ml\src"
"C:\Program Files\OpenCV\otherlibs\_graphics\src"
5. Download some OpenCV examples, e.g. from . I managed
to run only the first example (showing picture of a hand) and the 3rd (camera

Let's try the 3rd example now. You will need a camera connected to your PC.
I’ve tested the code using Logitech Quickcam. I would recommend testing
your camera on before running the code.

6. Unrar
tutorialOpenCV.rar to the folder where you keep your projects (e.g.

7. In VC++ open this project – “Select File”-> "Open" -> "Project/Solution.."

The VC++ will then run a Conversion Tool to convert a project written in older
version to the current version (see screenshots).
8. Once you've got the project opened (and converted), select "exemplo3-
tutorialOpenCV" in Solution Explorer, and open "Project" -> "Properties"
(or simply right click on the project and select "Properties")

9. Then go to "Configuration Properties" -> "Linker" -> "Input" (see

screenshot for next step)

10. Add the filenames of all necessary import libraries : cxcore.lib cv.lib
highgui.lib cvaux.lib cvcam.lib . You can find them in C:\Program
Files\OpenCV\lib . In this example only cxcore.lib cv.lib highgui.lib has been
Remember that if you change "Solution Configuration" from Debug to Release you
will need to add the OpenCV libraries to the “Additional Dependencies” again.

11. Build the project by pressing F7.

You will see a log generated in the output window:

------ Build started: Project: exemplo3-tutorialOpenCV, Configuration: Debug Win32 ------

cl : Command line warning D9035 : option 'clr:oldsyntax' has been deprecated and will be removed in
a future release
cl : Command line warning D9035 : option 'clr:oldsyntax' has been deprecated and will be removed in
a future release
Generating Code...
Compiling resources...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation. All rights reserved.
Embedding manifest...
Build log was saved at "file://c:\Documents and Settings\jakub\My Documents\Visual Studio
exemplo3-tutorialOpenCV - 0 error(s), 2 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

12. Hopefully everything went fine, and you can run the project by pressing F5