搜索
您的当前位置:首页OpenCV 2.1.0 with Visual Studio 2010(1)

OpenCV 2.1.0 with Visual Studio 2010(1)

来源:乌哈旅游

如果Debug下不能运行,则切换到Release版本下!!!(以前网上查到,不明真相)

实践中可用的方案1:


By 23. 六月 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, []
  • Download Visual Studio 2010, you can download an express edition []

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

Click Next button

Click I Agree button

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

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

Click Next button

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

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

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

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

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

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

 

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

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

 

Donate this article:   

当前评分 4.8 , 共有 4 人参与

 

因篇幅问题不能全部显示,请点此查看更多更全内容

Top