码迷,mamicode.com
首页 > 其他好文 > 详细

Visual Studio 2015 + OpenCV 2.4.9 开发环境搭建

时间:2017-07-04 00:56:05      阅读:311      评论:0      收藏:0      [点我收藏+]

标签:turn   build   open   war   vc++目录   .exe   cal   控制台   pre   

第一步

安装 Visual Studio 2015 (废话),别忘了勾选C++部分组件

第二步

下载 OpenCV https://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.9/opencv-2.4.9.exe/download

第三步

运行 opencv-2.4.9.exe,解压到指定目录,这里我们解压到 C:\OpenCV2.4.9

第四步

设置环境变量,系统Path,加上,C:\OpenCV2.4.9\opencv\build\x86\vc12\bin

第五步

下载 Visual Studio 2013 的 debug 库,放到上一步的 bin 目录,http://pan.baidu.com/s/1dFIjbt3

第六步

创建 C++ Win32 控制台项目,复制粘贴以下测试代码,在 C:\\users\maxwell\pictures 目录创建图片文件 a.bmp

#include <cv.h>
#include <highgui.h>
using namespace cv;
using namespace std;

int main()
{
    Mat img = imread("C:\\\\users\\maxwell\\pictures\\a.bmp");
    namedWindow("My Window");
    imshow("iMy IMG, img);
    waitKey(6000);
    return 0;
}

第七步

设置项目属性

VC++目录->包含目录,C:\OpenCV2.4.9\opencv\include;C:\OpenCV2.4.9\opencv\include\opencv;C:\OpenCV2.4.9\opencv\build\include\opencv2

库目录,C:\OpenCV2.4.9\opencv\build\x86\vc12\lib

C/C++->命令行->其他选项,/D_CRT_SECURE_NO_WARNINGS

连接器->输入->附加依赖项,

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

第八步

编译运行

 

Visual Studio 2015 + OpenCV 2.4.9 开发环境搭建

标签:turn   build   open   war   vc++目录   .exe   cal   控制台   pre   

原文地址:http://www.cnblogs.com/mxwl/p/7113497.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!