当前位置:Gxlcms > mysql > VisualStudio+Opencv2.4.9环境配置

VisualStudio+Opencv2.4.9环境配置

时间:2021-07-01 10:21:17 帮助过:16人阅读

【原文】http://blog.csdn.net/poem_qianmo/article/details/19809337 1 .下载和安装opencv sdk 从官网下载opencv 2.4.9安装包,解压到某个目录,路径最好为英文。比如我的:D:\opencv 2. 配置环境变量 系统变量 PATH中加入,注意分号分隔 对于32位系统:D:\

【原文】http://blog.csdn.net/poem_qianmo/article/details/19809337

1.下载和安装opencv sdk

从官网下载opencv 2.4.9安装包,解压到某个目录,路径最好为英文。比如我的:D:\opencv


2.配置环境变量

系统变量 PATH中加入,注意分号分隔

对于32位系统:D:\opencv\build\x86\vc12\bin (vs2010就是vc10,vs2012是vc11,vs2013是vc12)

对于64位系统:D:\opencv\build\x64\vc12\bin (可以两个都加上,这样在vs里面设置编译的平台是可以选择x86或者x64)

环境变量配置完后重启生效


3.工程包含(include)目录设置

针对包含目录和库目录可以在属性管理器里统一设置,对所有工程生效,这个方法省时省力,但是不建议,因为可能会影响其他工程。这里针对单个工程设置。

添加上

D:\opencv\build\include

D:\opencv\build\include\opencv

D:\opencv\build\include\opencv2

这三个目录。


4.工程库(lib)目录设置

添加上

D:\opencv\build\x86\vc12\lib

这个路径(64位也可以写x86或x64,与前面环境变量匹配,vc12对应vs2013)


5.链接库附加依赖项配置

对于【OpenCV2.4.9】,添加如下249版本的lib(这样的lib顺序是:19个带d的debug版的lib写在前面,19个不带d的release版的lib写在后面):

opencv_ml249d.lib
opencv_calib3d249d.lib
opencv_contrib249d.lib
opencv_core249d.lib
opencv_features2d249d.lib
opencv_flann249d.lib
opencv_gpu249d.lib
opencv_highgui249d.lib
opencv_imgproc249d.lib
opencv_legacy249d.lib
opencv_objdetect249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_nonfree249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_videostab249d.lib


opencv_objdetect249.lib
opencv_ts249.lib
opencv_video249.lib
opencv_nonfree249.lib
opencv_ocl249.lib
opencv_photo249.lib
opencv_stitching249.lib
opencv_superres249.lib
opencv_videostab249.lib
opencv_calib3d249.lib
opencv_contrib249.lib
opencv_core249.lib
opencv_features2d249.lib
opencv_flann249.lib
opencv_gpu249.lib
opencv_highgui249.lib
opencv_imgproc249.lib
opencv_legacy249.lib

opencv_ml249.lib

所粘贴内容即为之前我们解压的OpencV目录D:\opencv\build\x86\vc12\lib下所有lib库文件的名字


6.测试

前面配置及重启无误后,可以用以下代码做opencv读图测试,测试图片是大名鼎鼎的莱娜图^_^


#include 
#include   
#include   
using namespace cv;   
int main()  
{  
    // 读入一张图片  
    Mat img=imread("lena.jpg");  
    // 创建一个名为 "游戏原画"窗口  
    namedWindow("pictest");  
    // 在窗口中显示游戏原画  
    imshow("pictest",img);  
    // 等待6000 ms后窗口自动关闭  
    waitKey(6000);  
}  

人气教程排行