OpenCV 2.1.0 with Visual Studio 2010(1)

本文详细介绍了如何在Visual Studio 2010中配置并使用OpenCV 2.1进行计算机视觉开发。包括安装步骤、环境配置及常见问题解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

实践中可用的方案1:

http://blog.aguskurniawan.net/post/OpenCV-210-with-Visual-Studio-2010.aspx


OpenCV 2.1.0 with Visual Studio 2010

By Agus Kurniawan23. 六月 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:   

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值