转自:
http://blog.csdn.net/micheal_w/article/details/40316493
这里是博主的近几天捣鼓VS2008/VS2010和opencv的一些体会:
1. 博主是做图像处理这一块,涉及到的是VS2008/VS2010配置openCV相关知识;
2. VS2010及以上版本是眼下比较流行的C/C++的环境,配置openCV可实现图像处理很多工作,但是VS2010以上版本调试时bug较多,所以博主选择在bug较少的VS2008上先学习。
3.言归正传,VS2008环境配置opencv,这里以opencv2.3.1为例说明。
*****************************************************************************************************************************************************************************************
VS2008下配置opencv 2.3.1步骤:
*******************************************************************************************************************************************************************************************11. Download opencv2.3.1 file
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/
2. Download tbb40_20120408oss_win.zip
tbb40_20120408oss_win.zip
3. 提取opencv2.3.1保存在C:Program Filesopencv2.3.1(这里说明一下,openCV提取时自带有文件夹,就不用在目录下创建opencv子文件夹)
4. 讲下载的 tbb40_20120408oss_win.zip文件解压,copy到第3步创建的C:Program Filesopencv2.3.1opencv中;
5. 设置环境变量
本人用的是XP系统,步骤为:(右击) 我的电脑–>属性–>高级–>环境变量,
在用户变量中,添加Path变量值为:
C:Program Filesopencv2.3.1opencvuildx86vc9in;C:Program Filesopencv2.3.1opencv bb40_20120408ossinia32vc9
添加opencv变量值为:
C:Program Filesopencv2.3.1opencvuild
在系统变量中,修改Path的变量值:
C:Program Filesopencv2.3.1opencvuildx86vc9in;C:Program Filesopencv2.3.1opencv bb40_20120408ossinia32vc9
6. 在VS2008环境下配置opencv:
打开VS2008,依次点击Tools–>Options–>Projects and Solutions–>VC++ Directories
对于Include files,如图添加4个路径:
对于Library files,如图添加2个路径:
7. 在win32下创建一个project,添加依赖库(这里说明一下,依赖库来源于tbb40文件,在第5步设置环境变量时一定不要忘记添加哦~)
Project–>Properties–> Configuration Properties–>Linker–>Input–>Additional Dependencies
在debug下,添加
opencv_calib3d231d.lib
opencv_contrib231d.lib
opencv_core231d.lib
opencv_features2d231d.lib
opencv_flann231d.lib
opencv_gpu231d.lib
opencv_highgui231d.lib
opencv_imgproc231d.lib
opencv_legacy231d.lib
opencv_ml231d.lib
opencv_objdetect231d.lib
opencv_ts231d.lib
opencv_video231d.lib
在release下,添加
opencv_calib3d231.lib
opencv_contrib231.lib
opencv_core231.lib
opencv_features2d231.lib
opencv_flann231.lib
opencv_gpu231.lib
opencv_highgui231.lib
opencv_imgproc231.lib
opencv_legacy231.lib
opencv_ml231.lib
opencv_objdetect231.lib
opencv_ts231.lib
opencv_video231.lib
(这里说明一下,VS2008需要在新建的project下重新添加依赖库,所以当debug/release通不过时,首先检查你是否添加了依赖库哦!!!)
That‘s over!