opencv第二课,使用cmake编译OpenCV,并添加opencv_contrib模块

一、下载安装cmake

想要在Windows平台下生成OpenCV的解决方案,我们需要一个名为cmake的开源软件,可以在camke的官网:http://www.cmake.org/上下载到

或者点击此链接进行下载http://www.cmake.org/files/v2.8/cmake-2.8.12.2-win32-x86.exe

下载完成直接运行安装就行。

二、使用cmake生成OpenCV源代码工程的解决方案

在进行opencv_contrib模块添加时,一定要保证opencv和opencv_contrib的版本一致,要不然会失败!!!!!!!!

在进行opencv_contrib模块添加时,一定要保证opencv和opencv_contrib的版本一致,要不然会失败!!!!!!!!

在进行opencv_contrib模块添加时,一定要保证opencv和opencv_contrib的版本一致,要不然会失败!!!!!!!!

OpenCV: https://github.com/Itseez/opencv 
Extra Modules: https://github.com/Itseez/opencv_contrib

2.1、下载完OpenCV和opencv_contrib模块后进行解压,记得解压路径不要有中文。

2.2、运行cmake

opencv第二课,使用cmake编译OpenCV,并添加opencv_contrib模块

2.3、source code选择opencv路径,下面选择一个空的文件夹。

where is the source code:放源代码,路径如图。 
where to build the binaries:生成的代码放置位置,路径如图。 
2.4、然后点击“configure”按钮,弹出以下窗口,选择你对应的vs版本,然后点击“finish”就开始生成了。

opencv第二课,使用cmake编译OpenCV,并添加opencv_contrib模块

2.4、往opencv中添加opencv_contrib模块,找到OPENCV_EXTRA_MODULES_PATH,后面添加路径D:\opencv3\source\opencv_contrib\modules,精确到\modules。然后继续configure,一次之后如果还有红色的块,继续configure,知道全部变白为止。 
然后点击Generate,回提示Generate Done。恭喜,完成了一半!!!

opencv第二课,使用cmake编译OpenCV,并添加opencv_contrib模块

三、编译OpenCV源代码

在D:\opencv3\build下找到OPENCV.sln,打开,找到CMakeTargets下的INSTALL,在Debug和Release下分别右键生成即可。 
opencv第二课,使用cmake编译OpenCV,并添加opencv_contrib模块 
编译需要比较长的时间,我编译Debug和Release花了一个多小时。然后你就可以在D:\opencv3\build\install下看到 
opencv第二课,使用cmake编译OpenCV,并添加opencv_contrib模块
四、使用opencv环境配置 
1、首先设置环境变量,如下设置系统变量opencv第二课,使用cmake编译OpenCV,并添加opencv_contrib模块,命名为OPENCV_DIR,路径为D:\opencv3\build\install\x86\vc12,然后设置用户路径:opencv第二课,使用cmake编译OpenCV,并添加opencv_contrib模块 
新建->PATH(变量名),变量值为%OPENCV_DIR%\bin。 
PS:更简单的方法,直接设置绝对路径,新建PATH,然后路径里面放D:\opencv3\build\install\x86\vc12\bin。之所以采用以上的方法是如果以后更新opencv版本的话,不用重新配置。 
2、配置opencv工程属性 
找到属性管理器 
opencv第二课,使用cmake编译OpenCV,并添加opencv_contrib模块
打开后如图 
opencv第二课,使用cmake编译OpenCV,并添加opencv_contrib模块 
双击图中Microsoft.Cpp.Win32.use进行配置。 
opencv第二课,使用cmake编译OpenCV,并添加opencv_contrib模块
可执行文件目录:D:\opencv3\build\install\x86\vc12\bin 
包含目录: 
D:\opencv3\build\install\include 
D:\opencv3\build\install\include\opencv 
D:\opencv3\build\install\include\opencv2 
库文件目录:D:\opencv3\build\install\x86\vc12\lib 
然后是附加依赖项: 
opencv第二课,使用cmake编译OpenCV,并添加opencv_contrib模块
opencv_aruco320d.lib
opencv_bgsegm320d.lib
opencv_bioinspired320d.lib
opencv_calib3d320d.lib
opencv_ccalib320d.lib
opencv_core320d.lib
opencv_datasets320d.lib
opencv_dnn320d.lib
opencv_dpm320d.lib
opencv_face320d.lib
opencv_features2d320d.lib
opencv_flann320d.lib
opencv_fuzzy320d.lib
opencv_highgui320d.lib
opencv_imgcodecs320d.lib
opencv_imgproc320d.lib
opencv_line_descriptor320d.lib
opencv_ml320d.lib
opencv_objdetect320d.lib
opencv_optflow320d.lib
opencv_phase_unwrapping320d.lib
opencv_photo320d.lib
opencv_plot320d.lib
opencv_reg320d.lib
opencv_rgbd320d.lib
opencv_saliency320d.lib
opencv_shape320d.lib
opencv_stereo320d.lib
opencv_stitching320d.lib
opencv_structured_light320d.lib
opencv_superres320d.lib
opencv_surface_matching320d.lib
opencv_text320d.lib
opencv_tracking320d.lib
opencv_video320d.lib
opencv_videoio320d.lib
opencv_videostab320d.lib
opencv_xfeatures2d320d.lib
opencv_ximgproc320d.lib
opencv_xobjdetect320d.lib
opencv_xphoto320d.lib

点击应用,确定,然后就大功告成了!!!!

上一篇:一、SAP中添加一个模块到收藏夹后,显示事务代码


下一篇:关于java集合排序