Sei sulla pagina 1di 6

Mr 337 Random Thoughts

80% Linux, 10% Microsoft, and 10% Random? Search for:


Starting OpenCV development on Code Blocks (For Linux)

I am starting on a project called EconoBoard (source here) that hopefully is a cheap implementation of a SmartBoard. I didnt want to use a Wii controller because I wanted more control. I started using NetBeans to develop in C/C++ but was to slow so found Code Blocks. So far we have been in a happy relationship. I will teach you how to start developing with OpenCV in Code Blocks. 1. Make sure you have the dev files installed 2. Open Code Blocks and create new project of your pick. 3. Go To Project -> Build Options -> Linker Tab and add -lm -lcv -lhighgui -lcvaux in Other Linker Options text box. Should look something like this.

4. Next go to Search Directories Tab->Compiler Tab and add location of dev files. For me it was /usr/include/opencv/

5. Now add some test code. Couldnt think of anything good so try this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #include <stdio.h> #include <stdlib.h> #include <cv.h> #include <highgui.h> int main() { printf("Creating Window\n"); cvNamedWindow("Hello", 1); printf("Destroying Window\n"); cvDestroyWindow("Hello"); return 0; }

If everything is working should compile perfectly. Now if you want to add code completion go to Project->Properties->C/C++ Parser Options and add same director as dev files. Test and should look something like this. Have fun programming!

Yeah it's working

This entry was posted on Tuesday, March 31st, 2009 at 3:39 pm and is filed under Linux, Programming, Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Comments (13) Trackbacks 1. Stef says: September 4, 2009 at 5:51 pm Thank you! It is exactly what I was looking for! Good job. 2. Tho says: February 18, 2010 at 7:33 am Yeah thanks ^^ thats cool =3 3. Berial says: February 28, 2010 at 4:02 pm Hi Despite the fact that I added directory with header files to parser options, i dont have code completion. Could you help me with that? I use codeblocks 8.02 4. Berial says: February 28, 2010 at 4:15 pm I mean I dont have all function listed. For egzample I dont have listed such basic function as cvLoadImage()


admin says: February 28, 2010 at 6:54 pm First make sure that you have openCV installed. Double check the install directory. Since the post I have started using VIM, wish I could help you more. Another thing you could try is posting on Code::Blocks forum:,5.0.html Good Luck!


Sabrina says: March 3, 2010 at 5:08 am thank you so match!!!


medison says: May 8, 2010 at 10:48 pm thanks!


Vikram says: June 14, 2010 at 4:22 pm Thanks it was really helpful.


Elias says: February 23, 2011 at 8:32 am Thanks!!! I spend many hour trying do it on Windows, and when I change to linux and used your tutorial was quickly


jo says: April 4, 2011 at 5:02 pm to add code completion go to Project->Properties->C/C++ Parser Options and add same director as dev files. > I couldnt figure out the right directory for the parser file. Is there a standard path for the opencv-parser-file?


Pin-Yun says: April 4, 2011 at 8:07 pm Thank you. I am a student from Taiwan, your teaching help me so many. My English is not good but I want to say thanks for you.


admin says: April 4, 2011 at 9:04 pm

@jo Look at step #4. Its the same location as in the picture that I used (/usr/include/opencv). Now if you rolled your own or maybe have a weird distro it *might* be in another location. Something the locate command should be able to help you find if the opencv folder goes missing 1. Kendala Install OpenCV di Ubuntu 9.10 mediBlog says: May 10, 2010 at 5:54 am [...] Oya, kalau ada yang butuh informasi cara menjalankan OpenCV lewat CodeBlocks di Ubuntu 9.10, silahkan baca di sini. [...]

Leave a Reply
Name (required) Mail (will not be published) (required) Website

Submit Comment

Subscribe: Entries | Comments

Linux Microsoft Programming Robotics Uncategorized

June 2011 March 2011 January 2011 July 2010 April 2010 March 2010 October 2009

August 2009 April 2009 March 2009 December 2008 November 2008 August 2008 July 2008 June 2008 May 2008 April 2008 March 2008 February 2008

Development Blog Documentation Plugins Suggest Ideas Support Forum Themes WordPress Planet

Log in Valid XHTML XFN WordPress 2011. Mr 337 Random Thoughts. All rights reserved. Powered by WordPress & SimpleX theme.