opencv相对路径的配置

近来开始学习opencv图像处理,那么首先就要进行配置opencv的配置了。我这里采用的是VS2010+opencv2.4.10。

查阅了网上的博客,发现大多都是使用绝对路径添加,在不同的电脑上就得重新配置,如果直接把opencv,opencv2,lib文件夹拷到项目中会,会导致项目空间过大,不好拷贝。于是不断尝试,终于可以使用相对目录进行配置。下面以win10为例

1.在环境变量中添加OPENCV变量

点击此电脑-属性-环境变量,在系统变量中,点击新建,变量名为OPENCV,变量值为你电脑当中opencv的目录

opencv相对路径的配置_第1张图片

2.在系统变量中的Path变量中,添加%OPENCV%\build\x64\vc10\bin目录,我这里是采用Debug64编译,如果你是debug32,就将x64改成x86。

3.重启电脑,不然环境变量无法生效。

4.新建一个C++项目,我采用的是mfc,打开属性页,在VC++目录中包含目录中添加

5.在库目录中添加

6.接下来点击链接器-输入,添加附加依赖项

如果是Debug模式,添加以下

opencv_ml2410d.lib

opencv_calib3d2410d.lib

opencv_contrib2410d.lib

opencv_core2410d.lib

opencv_features2d2410d.lib

opencv_flann2410d.lib

opencv_gpu2410d.lib

opencv_highgui2410d.lib

opencv_imgproc2410d.lib

opencv_legacy2410d.lib

opencv_objdetect2410d.lib

opencv_ts2410d.lib

opencv_video2410d.lib

opencv_nonfree2410d.lib

opencv_ocl2410d.lib

opencv_photo2410d.lib

opencv_stitching2410d.lib

opencv_superres2410d.lib

opencv_videostab2410d.lib

 

如果是release,添加如下

opencv_ml2410.lib

opencv_calib3d2410.lib

opencv_contrib2410.lib

opencv_core2410.lib

opencv_features2d2410.lib

opencv_flann2410.lib

opencv_gpu2410.lib

opencv_highgui2410.lib

opencv_imgproc2410.lib

opencv_legacy2410.lib

opencv_objdetect2410.lib

opencv_ts2410.lib

opencv_video2410.lib

opencv_nonfree2410.lib

opencv_ocl2410.lib

opencv_photo2410.lib

opencv_stitching2410.lib

opencv_superres2410.lib

opencv_videostab2410.lib

 

7.最后在项目头文件中添加

#include                
#include     

using namespace cv;

opencv到此结束,可以正常的使用opencv自带的函数了   

你可能感兴趣的:(C++内存问题,MFC,opencv)