1.下载opencv2.4.10,百度网盘链接如下:
链接:https://pan.baidu.com/s/1UdoQJbRUEB_G2urT703xYQ
提取码:7lbd
2.运行opencv-2.4.10.exe,将文件提取到一个自定义目录里:
3.添加系统环境变量
在“系统变量”里找到“path”这个变量,点击“编辑”
点击“新建”
win32
D:\softwareEnv\opencv\build\x86\vc10\bin
X64
D:\softwareEnv\opencv\build\x64\vc10\bin
添加完后重启电脑生效。
4.打开VS2010,新建一个MFC项目 :
在项目文件夹右键属性
5. 配置属性->VC++目录->包含目录中添加:
D:\softwareEnv\opencv\build\include
D:\softwareEnv\opencv\build\include\opencv
D:\softwareEnv\opencv\build\include\opencv2
在包含目录中添加:
Win32配置:
D:\softwareEnv\opencv\build\x86\vc10\lib
X64配置:
D:\softwareEnv\opencv\build\x64\vc10\lib
在链接器->输入->附加依赖项中添加:
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
6.测试代码
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
Mat img=imread("C:\\Users\\GuangshengLi\\Desktop\\1.png");
imshow("img",img);
7.运行结果如下:
大功告成,opencv环境配置成功!
参考博客:VS2010(VC10)配置opencv2.4.10_vs2010 + opencv-2.4.10-CSDN博客
OpenCV2.4.10+VS2010开发环境配置_opencv 2.4.10-CSDN博客