VC6下安装与配置OpenCV1.0
本手册适应 OpenCV 1.0 安装。
目录 [隐藏]
1 安装Visual C++ 6.0
2 安装OpenCV
3 配置Windows环境变量
4 配置Visual C++ 6.0
4.1 全局设置
4.2 项目设置
[编辑]安装Visual C++ 6.0
注:截止2010年4月4日,还没有在VC6.0下成功使用opencv2.0的案例。采用VC6.0的用户请采用
opencv1.0版本
[编辑]安装OpenCV
从http://www.opencv.org.cn 下载OpenCV安装程序。假如要将OpenCV安装到C:/Program Files/OpenCV
。(下面附图为OpenCV 1.0rc1的安装界面,OpenCV 1.0安装界面与此基本一致。)在安装时选择"将
/OpenCV/bin加入系统变量"(Add/OpenCV/bin to the systerm PATH)。
[编辑]配置Windows环境变量
检查C:/Program Files/OpenCV/bin是否已经被加入到环境变量PATH,如果没有,请加入。加入后需要注
销当前Windows用户(或重启)后重新登陆才生效。(可以在任务管理器里重启explorer.exe)
运行“开始->所有程序->OpenCV->OpenCV Workspace MSVC6"
或者在VC6.0里面打开opencv的根目录下工作空间"C:/Program Files/OpenCV/_make/opencv.dsw"
配置为win32 debug 模式,创建(Build)这时会出现三个错误:
cvbgfg_acmmm2003.cpp
C:/Program Files/OpenCV/cvaux/src/cvbgfg_acmmm2003.cpp(411) : error C2039:
'foreground_regions' : is not a member of 'CvFGDStatModel'
../include/cvaux.h(1240) : see declaration of 'CvFGDStatModel'
C:/Program Files/OpenCV/cvaux/src/cvbgfg_acmmm2003.cpp(416) : error C2039:
'foreground_regions' : is not a member of 'CvFGDStatModel'
../include/cvaux.h(1240) : see declaration of 'CvFGDStatModel'
cvbgfg_common.cpp
cvbgfg_gaussmix.cpp
C:/Program Files/OpenCV/cvaux/src/cvbgfg_gaussmix.cpp(343) : error C2039:
'foreground_regions' : is not a member of 'CvGaussBGModel'
../include/cvaux.h(1300) : see declaration of 'CvGaussBGModel'
打开cvaux.h,在1137行CvMemStorage* storage;(或者查找key)后面的注释语句出问题了,把下一行屏蔽了,注释语句修改
CvMemStorage* storage; /*storage for 揻oreground_regions?/ /
CvSeq* foreground_regions /*foreground object contours*/
-->
CvMemStorage* storage; /*storage for 揻oreground_regions*/ /
CvSeq* foreground_regions /*foreground object contours*/
再次build all,错误消除,将各个工程分别编译链接生成.dll文件。
至此,opencv配置完毕。
[编辑]配置Visual C++ 6.0
[编辑]全局设置
菜单Tools->Options->Directories:先设置lib路径,选择Library files,在下方填入路径:
C:/Program Files/OpenCV/lib
然后选择include files,在下方填入路径:
C:/Program Files/OpenCV/cxcore/include
C:/Program Files/OpenCV/cv/include
C:/Program Files/OpenCV/cvaux/include
C:/Program Files/OpenCV/ml/include
C:/Program Files/OpenCV/otherlibs/highgui
C:/Program Files/OpenCV/otherlibs/cvcam/include
然后选择source files,在下方填入路径:
C:/Program Files/OpenCV/cv/src
C:/Program Files/OpenCV/cxcore/src
C:/Program Files/OpenCV/cvaux/src
C:/Program Files/OpenCV/otherlibs/highgui
C:/Program Files/OpenCV/otherlibs/cvcam/src/windows
最后点击“ok”,完成设置。
[编辑]项目设置
每创建一个将要使用OpenCV的VC Project,都需要给它指定需要的lib。菜单:Project->Settings,然
后将Setting for选为All Configurations,然后选择右边的link标签,在Object/library modules附加
上
cxcore.lib cv.lib ml.lib cvaux.lib highgui.lib cvcam.lib
如果你不需要这么多lib,你可以只添加你需要的lib。