前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >win 7 + VC++ 2008 express + OpenCv 2.1.0安装

win 7 + VC++ 2008 express + OpenCv 2.1.0安装

作者头像
s1mba
发布2018-01-03 17:41:14
8000
发布2018-01-03 17:41:14
举报

官方文档并注释:

These instructions were tested with Visual C++ 9.0 (as part of Visual Studio 2008 Professional). These instructions should work without modification with Visual Studio 2005 and 2003. Modifications may be necessary for Visual Studio Express editions. These instructions do not apply to Visual Studio 2010 which uses different settings (see VisualC++).

Install OpenCV

Download the OpenCV 2.1.0 Windows installer from SourceForge - "OpenCV-2.1.0-win32-vs2008.exe".

Install it to a folder (without any spaces in it), say "C:\OpenCV2.1\". This article will refer to this path as $openCVDir

During installation, enable the option "Add OpenCV to the system PATH for all users".

由于有些函数需要TBB,所以需要将tbb所在的目录也加入到环境变量Path中如C:\TBB\bin\ia32\vc9   加入后可能需要注销当前Windows用户(或重启)后重新登陆才生效

Configure Visual Studio

Open VC++ Directories configuration: Tools > Options > Projects and Solutions > VC++ Directories

Choose "Show directories for: Include files"

Add "$openCVDir\include\opencv"

Choose "Show directories for: Library files"

Add "$openCVDir\lib"

  如果使用了DirectShow,  Add  "../DirectShow/Lib"(看具体情况)

Choose "Show directories for: Source files"

Add "$openCVDir\src\cv"

Add "$openCVDir\src\cvaux"

Add "$openCVDir\src\cxcore"

Add "$openCVDir\src\highgui"

Add "$openCVDir\src\ml"

Configure your Project

After you've created a project you'll need to add the OpenCV dependencies.(debug 和release 都添加)

Open Project Properties: Project > %projectName% Properties...

Open Linker Input properties: Configuration Properties > Linker > Input

Open the "..." window to edit "Additional Dependencies" and on each line put:

"cv210.lib"

"cxcore210.lib"

"highgui210.lib"

“ml210.lib”

“cvaux210.lib”

And any other lib file necessary for your project

注意,请打开了新编辑窗口(即点击了“...”按钮)“附加依赖项”,并一条一条分别加入,一条一行(一个回车),(注意行末不要加";")否则会出现类似以下错误:1>LINK : fatal error LNK1104: 无法打开文件“…….lib”

Your project should now build. If you get any errors try restarting Visual Studio and then doing a clean Rebuild.

如果使用了DirectShow or DirectX, 在vs的解决方案资源管理器中右键相应的项目,选择属性,在属性窗口的 配置属性 -> C/C++ -> 常规 中的 附加包含目录,点击其右边的小按钮,在弹出的附加包含目录中,确保条目 $(WindowsSdkDir)\include 和 $(FrameworkSDKDir)include 在任何dx目录如..\DirectShow\Include的前面。如果要在全局配置添加头文件目录,也要遵循这个原则

用下面的程序测试:

// OpenCV_Helloworld.cpp : Defines the entry point for the console application.

// Created for build/install tutorial, Microsoft Visual C++ 2008 Express and OpenCV //2.1.0

#include "stdafx.h"

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

int _tmain(int argc, _TCHAR *argv[])
{
    IplImage *img = cvLoadImage("e.jpg");
    cvNamedWindow("Image:", 1);
    cvShowImage("Image:", img);
    cvWaitKey();
    cvDestroyWindow("Image:");
    cvReleaseImage(&img);
    return 0;
}

//双击exe的话,e.jpg图片放在.exe(先bulid)同一文件夹内;按F5直接运行程序的话,

//e.jpg要放在opencv\opencv里

参考:OPencvChina官网

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2013-04-15 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档