win10下vs2017+opencv2.4.9配置教程

一、安装vs2017

二、安装opencv2.4.9

三、vs2017+opencv2.4.9配置

1)配置环境变量

打开控制面板--系统和安全--系统--高级系统设置--系统变量--path--编辑

添加opencv的路径

D:\Opencv249\opencv\build\x86\vc12\bin

【注意】路径根据自己的安装路径来写

win10下vs2017+opencv2.4.9配置教程_第1张图片

win10下vs2017+opencv2.4.9配置教程_第2张图片

win10下vs2017+opencv2.4.9配置教程_第3张图片

2)配置vs2017

打开vs2017,建立一个空项目

win10下vs2017+opencv2.4.9配置教程_第4张图片

新添加一个源文件

win10下vs2017+opencv2.4.9配置教程_第5张图片

win10下vs2017+opencv2.4.9配置教程_第6张图片

依次点击视图--其他窗口--属性管理器,在属性管理器窗口点击“Microsoft.Cpp.Win32.user

win10下vs2017+opencv2.4.9配置教程_第7张图片

点击VC++目录,在包含目录中添加

D:\Opencv249\opencv\build\include

D:\Opencv249\opencv\build\include\opencv

D:\Opencv249\opencv\build\include\opencv2

库目录中添加

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

【注意】根据自己的安装路径来添加

win10下vs2017+opencv2.4.9配置教程_第8张图片

点击连接器--输入--附加依赖项,添加以下库:(19个带d的debug版lib在前,19个不带d的release版在后)

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

 win10下vs2017+opencv2.4.9配置教程_第9张图片

配置完成,重启

在建好的源文件中添加下述代码

 

#include  
#include  
#include  

using namespace cv;

int main()
{
// 读入一张图片
Mat img = imread("img.jpg");
// 创建一个名为 "img"窗口  
cvNamedWindow("img");
// 在窗口中显示demo  
imshow("img", img);
// 等待
waitKey(0);
}

若成功显示图片,则配置成功

 

你可能感兴趣的:(OpenCV)