Description
This tutorial explains you how to integrate the computer vision library OpenCV in the Dev-C++ IDE.
At the end of this how-to, you will be able to use OpenCV to write C++ programs, which use webcams or other video sources and which can detect persons, motions, outlines of objects...
Please note: this tutorial refers to the OpenCV version 1.0rc1. See the modifications at the end of this page if you like to use the newer version 1.1pre1!
OpenCV (Open Source Computer Vision Library) is a C++ library from Intel for image processing.
The OpenCV library contains various algorithms and offers many applications:
Dev-C++ is a open source development environment (IDE) for C and C++.
The IDE runs with Windows and uses a varaint of the GNU-C++ compiler.
One of the greatest advantages is the clearly arranged user interface, which doesn't slow down your work with needless features and makes it easier for beginners to become familiar with it.
In this how-to I will assume, that you already have installed Dev-C++ on your system.
Λ Back to top
Installation of OpenCV
The first step is to download OpenCV from
http://sourceforge.net/projects/opencvlibrary/.
The version used in this tutorial is named "OpenCV_xyz.exe" and located in the package "opencv-win" (xyz stands for the version).
Direct link to the
download of version 1.0rc1
(

16 MB), auf welche sich diese Anleitung bezieht.
Now you must run the downloaded setup program. If you keep all default setting during installation (recommended!), OpenCV will be installed to C:\Program Files\OpenCV.
After the installation you'll need to reboot your system, due to changed path settings (C:\Program Files\OpenCV\bin).
You will find some example programs in C:\Program Files\OpenCV\samples\c.
Some of them require a connected webcam (or other video source) to work.
Λ Back to top
Configuration of Dev-C++
In Dev-C++ open the menu "Tools->Compiler options".
In the first tab("Compiler") you need to check the box "Add these commands to the linker command line" and type the following line in the text bow below:
-lhighgui -lcv -lcxcore -lcvaux -lcvcam
Go to the sub-tab "Libraries" in the tab "Directories" and add there
C:\Program Files\OpenCV\lib to the paths:
Now switch to the sub-tabs "C Includes" and "C++ Includes" and add this paths:
C:\Program Files\OpenCV\cxcore\include
C:\Program Files\OpenCV\cv\include
C:\Program Files\OpenCV\otherlibs\highgui
C:\Program Files\OpenCV\cvaux\include
C:\Program Files\OpenCV\otherlibs\cvcam\include
Λ Back to top
That's all!
Well, this wasn't too hard. Now you should be able to open a sample file - for e.g. C:\Program Files\OpenCV\samples\c\squares.c and compile and run it with Dev-C++ (F9).
And of course you may modify it and do your own experiments with OpenCV...
You'll find the OpenCV documentation here:
OpenCV documentation
Have fun!
Cypax
Λ Back to top
Links and files
OpenCV (Intel)
OpenCV (Wikipedia)
OpenCV project (Sourceforge)
Bloodshed Dev-C++
Dev-C++ Resource Site
OpenCV Version 1.0rc1 (16MB)
Λ Back to top
Update: Modifications for OpenCV 1.1pre1
In the meantime there is a newer OpenCV version
1.1pre1 availabale on
Sourceforge.
There is no more cvcam library with this newer version. From the changelog:
[Windows] cvcam has been removed (as videoInput is now supported by highgui)
If you like to use this version you must notice the following points:
- During installation of OpenCV you will be asked whether the path C:\Program Files\OpenCV\bin shall be added to the PATH environment variable.
Please leave this checked (default).
- After installation you should restart Windows to accept PATH changes.
- When configuring Dev-C++ do not add
-lhighgui -lcv -lcxcore -lcvaux -lcvcam to the linker command line.
The correct phrase is: -lhighgui -lcv -lcxcore -lcvaux. Thus without -lcvcam!
- Do not add path
C:\Program Files\OpenCV\otherlibs\cvcam\include to the sub-tabs "C Includes" and "C++ Includes".
This path no longer exists with the 1.1pre1 version.
Λ Back to top
Write a new comment:
Dear visitor,
I'm looking forward to every new entry.
But I'd like to ask you to pay attention to the following points:
Due to continuous spambot attacks it is necessary to enter the number below the form before sending.
This captcha (?) protects the guestbook
to be overwhelmed by advertisements for viagra or similar enjoyablenesses.
Furthermore I like to point out that your host and IP will be logged.
Entries with extremist, pornographic, insulting or otherwise illegal content are forbidden.
Also advertisement for commercial products or websites is strictly prohibited.
Hyperlinks in the guestbook are not possible.
Infringements may be reported to justice.
Each message may have up to 500 letters.
Thank you for respecting this rules.
14 comments. Oldest comment first:
1. ollydbg wrote on 17-Dec-2008 at 15:24:56:
GREAT!
Follow your advice, I can also do it in code::blocks and Mingw. Thanks!
2. Aidan wrote on 05-Jan-2009 at 23:54:09:
Thanks so much! These tutorials will help me a lot, and I couldn't figure out how to get OpenCV 1.1pre1 to work with Dev-Cpp so this helped me ALOT. Thanks again!
3. ollydbg wrote on 07-Jan-2009 at 03:51:55:
to: Aidan
It can easily upgrade to opencv1.1, I'm using codeblocks which also use mingw c++ compiler internally. Note there is only ONE header file path and ONE library path you need to set.
4. John wrote on 13-Feb-2009 at 02:48:10:
jk_casey [at] live.com
Hi,
Thank for your page. I was trying to use cvcam and until now I didn't realise i had downloaded the wrong version of OpenCV as it didn't work with the demo provided. I am using DevCpp.
Now to find demos for the new version ...
Cheers,
John
5. Peet wrote on 11-Apr-2009 at 21:27:32:
Hi, I'd just like to mention that modifications to the PATH do not require a system restart - explorer.exe simply needs to be terminated and relaunched.
6. le PUISSANT wrote on 28-Jun-2009 at 21:30:29:
jolie laisseur de choix
7. linker error with opence wrote on 03-Jul-2009 at 23:05:20:
i get a linker error with opencv
8. Bishesh wrote on 18-Jul-2009 at 01:51:05:
Thanks,
This worked fine and will help me get started with openCV!
9. Bishesh wrote on 18-Jul-2009 at 11:11:03:
Sorry, I though it worked out fine earlier because I was able to compile the example OpenCV codes successfully.
BUT there is a problem when I run the program, application hangs and message: "an application failed to initialize ...".
If I use simple programs without OpenCV, it runs.
I am using vista.
When I try to use debug, I get:
program raises an Access Violation (Segmentation Fault)
I am using latest version of both openCV and devc++
10. patrick cadelina wrote on 03-Oct-2009 at 15:00:33:
hi. can you make a new guide for the new release of OpenCV 2.0?
Hello Patrick,
I'm curious about new features of OpenCV2 too, but since I'm currently quite busy with work there is just not enought room.
But I hope I'll find some time during the winter months for a new robotic project involving image processing.
- Cypax
11. Fab pinner wrote on 29-Oct-2009 at 06:49:47:
hope you can find some time to make some guide, I just can´t make the .lib files that you are supposed to work with Opencv 2.0.
12. Lars wrote on 05-Nov-2009 at 19:52:37:
Hi,
schöne Anleitung, aber leider habe ich beim compilen von squares.c den Fehler "cannot find -Ihighgui" und "ld returned 1 exit status".
Hast Du eine Idee was da falsch läuft?
13. sudeepta wrote on 20-Nov-2009 at 15:51:29:
Thats really well explained then any where else,
I wish you please tell how to configure Opencv2.0 with dev c++ I am having a very hard time with that.
Please give some tutorial please please please...
14. Mounica wrote on 10-Jan-2010 at 05:48:47:
Thanks a million! this tutorial really saved my time.
Λ back to top