Wednesday, March 31, 2010

Configure OpenCV 2.0 on Visual Studio 2008 for VC++

You must be hating OpenCV 2.0 by now :) But don’t worry your pain will go soon (if yes, please write a comment). The biggest pain is that you will have to compile your OpenCV using CMake and all those stuff (as explained here). But if you are content with C or C++ and not interested in debugging inside OpenCV or Python then read further.

Download and Install, Emgu which is actually .NET wrapper for OpenCV but we will just use their precious .lib files which otherwise is pain in neck to generate (Download Emgu from here: http://sourceforge.net/projects/emgucv/)

After Emgu installation, Open Visual Studio and follow these steps:

1. Go to Tool –> Options –> Projects and Solutions –> VC++ Directories

2. Now see a combobox “Show Directories for” and select “Include files” and add, “C:\Program Files\Emgu\Emgu CV\opencv\include\opencv” (verify, as program file location may differ if you are using 64 bit operating system)

3. Now in the same combobox select “Library files” and add, “C:\Program Files\Emgu\Emgu CV\lib\release

4.  Now go to your VC++ project, right click and go to Properties –> Configuration Properties –> Linker –> Input –> Additional Dependencies and add these lib files (which is at  C:\Program Files\Emgu\Emgu CV\lib\release) cv200.lib cvaux200.lib cxcore200.lib highgui200.lib (check library name, it may change according to OpenCV version used for the Emgu)

5. That’s it. Done for now. Take shot at compiling your VC++ code downloaded from internet ;)

NOTE: If you are interested in going into OpenCV library code while debugging then this may not be the best solution for you as Emgu only gives release .lib files. You will have to generate ‘debug’ lib files as described in http://mirror2image.wordpress.com/2009/10/20/switching-to-opencv-2-0-with-vs2005/

I am not sure but this same should help to configure VS 2010 also.

6 comments:

Anonymous said...

Hi Yogee,

I tried to make a simple program "LoadImage" by emguCV with VC++ in Windows Form Application as per your instruction.

But It did not help.

Could you please post screenshot of the stetps explain how to configure the project to use emguCV by making a sample program.


Thanks alot in advance.

Fahied

Yogee said...

Fahied,
This blog is more about configuring OpenCV. Emgu should work strait forward if you install using MSI. See link below if it helps. Let me know if you still have problem. I installed Emgu and did no other setting and worked perfectly. The problem may occur if you install visual studio after Emgu. If so, uninstall and reinstall Emgu.
http://www.emgu.com/wiki/index.php/Download_And_Installation#Creating_a_New_Project_in_Visual_Studio

Anonymous said...

Thank man, it worked.

admin said...

hi yogee, thx to your info, and this is my opencv configuration, keep share:)

install opencv 2.0 to visual c++ 2010 Express, here: http://arie-fardiansyah.blogspot.com/2010/09/install-opencv-20-ke-visual-c-2010.html

install opencv 2.0 to Dev-C++ 4.9.9.2, here: http://arie-fardiansyah.blogspot.com/2010/09/install-opencv-20-ke-dev-c-4992.html

Yogee said...

Arie,
Great to see other ports also. Keep up good work.
Thanks,
yogee

Anonymous said...

thanx it works for me !