OpenCV 2.4.9 +VS2013 开发环境配置

最近学习图像处理,为此在windows平台下使用visual studio2013和opencv2.4.9配置一个开发环境。

环境:win7 64位

工具:opencv 2.4.9   下载地址:http://opencv.org/downloads.html

         vs2013

步骤:

1.安装opencv2.4.9,解压,请务必记住自己解压的路径。以我的路径为D:\OPENCV


2.配置环境变量

我的电脑右键-->属性-->高级系统设置


2.1系统变量 Path:添加D:\OPENCV\opencv\build\x86\vc12\bin


2.2用户变量:添加opencv变量,值D:\OPENCV\opencv\build,添加PATH变量(有就不需要添加,但是值需要添加)值D:\OPENCV\opencv\build\x86\vc12\bin

说明:不管你系统是32位还是64位,路径目录均选择X86,因为编译都是使用32位编译。

3.启动vs2013, 新建一个 visual C++项目

新建 visual C++项目,如下图所示,项目选项注意:



4.工程目录的配置(Debug)

找到属性管理器,如果找不到,请安装下图方法找到。双击Debug|Win32打开如下窗口,


设置如下:(下图红框项为设置项)

4.1包含目录:(VC++目录)

D:\Program Files\opencv\build\include

D:\Program Files\opencv\build\include\opencv

D:\Program Files\opencv\build\include\opencv2

4.2库目录:(VC++目录)D:\Program Files\opencv\build\x86\vc12\lib


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

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

其实以上都是D:\Program Files\opencv\build\x86\vc12\lib下所有的lib文件,你会发现,有的后面带上d,有的没有d,这是因为Debug的就有d,Release则没有d。


5.工程目录的配置(Release)

其他与Debug一样,只是连接器->输入->附加依赖项不一样,设置如下:

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


测试:

#include <opencv2/opencv.hpp>
  
using namespace std;
using namespace cv;
  
int main(int argc, char* argv[])
{
    const char* imagename = "xiongmao.jpg";在opencvtest.cpp所在的工程目录下
  
    //从文件中读入图像
    Mat img = imread(imagename);
  
    //如果读入图像失败
    if(img.empty())
    {
        fprintf(stderr, "Can not load image %s\n", imagename);
        return -1;
    }
  
    //显示图像
    imshow("image", img);
  
    //此函数等待按键,按键盘任意键就返回
    waitKey();
  
    return 0;
}
运行如果可以看到熊猫的图片,就说明配置成功了。

你可能感兴趣的:(opencv,图像处理,VS2013)