Jika anda merasa blog ini bermanfaat dan berharap tetap berkelanjutan baik website maupun content-nya maka anda dapat berpartisipasi dengan memberikan donasi pada website ini. Donasi lewat Paypal dibawah ini.

If you think this website is usefull and want to this website that can still exist and keep content maintenance then you can participate to donate this website. Donate via Paypal as below.

OpenCV 2.1.0 with Visual Studio 2010

by Agus Kurniawan 23. June 2010 00:24

OpenCV (Open Source Computer Vision) is a library of programming functions for real time computer vision. Two months ago OpenCV released the new version of OpenCV 2.1. On this article, I would like to share how to use OpenCV with Visual Studio 2010.

System Requirements

  • Download OpenCV 2.1 or the latest, [V]
  • Download Visual Studio 2010, you can download an express edition [V]

I use Windows 7 x64 as development environment.

OpenCV 2.1 Installation

After you downloaded OpenCV library. Click setup file and then you’ll get a dialog as below

inst1

Click Next button

inst2

Click I Agree button

inst3

Choose Do not add OpenCV to the system PATH (you may choose any option) and then click Next button

inst4

Choose Destnation Folder that you want to store OpenCV files. After that, click Next button

inst5

Click Next button

inst6

Select the type of install Full. After that click Install button. Installer will install OpenCV library on your system.

inst7

Click Finish button to finish installation process.

Now you can see OpenCV 2.1 on your system. You can check on folder where OpenCV installed

openCV

Visual Studio 2010 Project Configuration

After you created a C/C++ project on Visual Studio 2010 you should configure OpenCV on Visual Studio 2010. Open properties dialog of project. Assume your OpenCV 2.1 installed on C:\OpenCV2.1

On properties dialog, click C/C++ –>General and entry C:\OpenCV2.1\include\opencv in Additional Include Directories

conf1

On properties dialog, click C/C++ –>Advanced and select Compile As. If you prefer C compiler, use Compile as C Code (/TC) 

conf2

On properties dialog, click Linker –>General and entry C:\OpenCV2.1\lib in Additional Library Directories

conf3

On properties dialog, click Linker –>Input and entry all *.lib files in Additional Dependencies. If you’re running on debug mode, try to entry all *d.lib files

 conf4

conf5

After you do all tasks above, click OK button on Propeties dialog.

Testing

For testing purpose, try to write this code (*note* change image file c:/temp/monas.jpg)

#include <stdio.h>
#include <highgui.h>
int main( int argc, char** argv ) 
{	
	IplImage* img = cvLoadImage( "c:/temp/monas.jpg",1 );
	cvNamedWindow("Monas", CV_WINDOW_AUTOSIZE );
	cvShowImage("Monas", img );
	cvWaitKey(0);
	cvReleaseImage( &img );
	cvDestroyWindow("Monas");
} 

Compile and run it. If success, you get image viewer dialog as below

monas

when you run this code from Visual Studio  and get error as below. Try to copy *.dll from OpenCV (C:\OpenCV2.1\bin) on folder where your executable file was located

error


Donate this article:

Tags:

C/C++ | OpenCV

Comments

8/6/2010 7:45:56 PM #

Web Development

Now a days Blogengine is going more popular as its quite good to use for blog sites, navigation provided  is so simple and easy and  because of this reason I inspired to write something  on the blog you have. And one more thing is that your content is too much informative.

Web Development United States

8/19/2010 11:35:45 PM #

leonardosalvatore

Hi,
all is good but i have to add also this folder C:\OpenCV2.1\include\opencv in the C\C++ Additional Include.
I'm on a Win7 64 vs2010 ultimate.

in any case, ty.

leonardosalvatore Italy

Add comment


(Will show your Gravatar icon)

  Country flag

Click to change captcha
biuquote
  • Comment
  • Preview
Loading



About Agus Kurniawan

Agus Kurniawan

For more detail about me click here [V]

Please entry your name into my guestbook [V]

My Facebook



Agus Kurniawan is Microsoft MVP (Most Valuable Professional)