OpenCV的一点体验,结合OpenCV中文网站的介绍整理如下:Step1:从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)。(一般按默认设置就可以,在我的电脑--属性---高级--环境变量中可以查看这一路径,如果没有可以手动添加,这其实就是加载动态链接库.dll,具体可见VC技术内第五版动态链接库一章给出了解释,这也给我一个启发,不一定需要每次在自己的程序发布版本中添加DLL,可以像这样直接设定路径 )
附VC技术内第五版动态链接库:
How the Client Program Finds a DLL
If you link explicitly with LoadLibrary, you can specify the DLL's full pathname. If you don't specify the pathname, or if you link implicitly, Windows follows this search sequence to locate your DLL:
The directory containing the EXE file
The process's current directory
The Windows system directory
The Windows directory
The directories listed in the Path environment variable
Here's a trap you can easily fall into. You build a DLL as one project, copy the DLL file to the system directory, and then run the DLL from a client program. So far, so good. Next you rebuild the DLL with some changes, but you forget to copy the DLL file to the system directory. The next time you run the client program, it loads the old version of the DLL. Be careful!
Step2:打开VC++6.0,在不建立工程前设置(通用设置)
菜单Tools->Options->Directories:先设置lib路径,选择Library files,在下方填入路径:
C:/Program Files/OpenCV/lib
然后选择include files,在下方填入路径:
C:/Program Files/OpenCV/cxcore/includeC:/Program Files/OpenCV/cv/includeC:/Program Files/OpenCV/cvaux/includeC:/Program Files/OpenCV/ml/includeC:/Program Files/OpenCV/otherlibs/highguiC:/Program Files/OpenCV/otherlibs/cvcam/include
Step3:每创建一个将要使用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
OpenCV类库了,当然在头文件中需要添加OpenCV的头文件,这些将在以后的日志中介绍。设定好OpenCV的编程环境后,我想到了CxImage,它没有OpenCV那样的安装文档,lib文件也分散在各个独立的文件中,以前设置环境总是非常麻烦,建立一个项目就要设置一次,现在就不用了,首先我把要用到的lib文件和头文件全部拷贝至新建的文件夹中: d:/ThirdParty/CxImage/lib和d:/ThirdParty/CxImage/include中,这样只要仿造上述第二步就可以在新建的项目中通用了。