VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程

VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程

  • 前言
  • 相关文件的下载
  • cmake编译OpenCV3.2.0
    • 1.指定源码目录及build目录
    • 2.点击config
    • 3.config中间可能遇到的问题
      • (1)卡在Downloading opencv_ffmpeg64.dll...
      • (2)卡在Downloading ippicv_windows_20151201.zip
    • 4.编译成功后
    • 5.添加扩展模块
    • 6.加入CMAKE_DEBUG_POSTFIX
    • 7.再次点击config
    • 8.点击generate
    • 9.点击OpenCV.sln文件
    • 10.生成install文件
    • 11.此时可以进行属性配置等操作了
  • 编译后的文件

前言

因之前的环境是vs2013的,又需要可以在vs2013上使用的带有扩展模块的OpenCV3.2.0版本,目前在网络上并未搜到相关已编译成功的OpenCV,故根据网上已有教程自己通过使用cmake对OpenCV的源码即扩展模块进行编译,用来生成,可以在vs2013上使用的OpenCV库。

相关文件的下载

1、下载OpenCV3.2.0:
https://github.com/opencv/opencv/archive/3.2.0.zip.
2、下载opencv_contrib3.2.0:
https://codeload.github.com/opencv/opencv_contrib/zip/3.2.0/.
3、下载cmake(本人使用的是cmake-3.14.0-win64-x64.zip):
https://cmake.org/files/.

cmake编译OpenCV3.2.0

参考链接:https://blog.csdn.net/simonforfuture/article/details/78925021

1.指定源码目录及build目录

在cmake-3.14.0-win64-x64\bin下直接双击cmake-gui.exe即可打开cmake。然后进行cmake,指定opencv3.2.0的源码目录和build目录如下:
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第1张图片

2.点击config

此处本人编译的是X64位的,即可以在VS2013的X64环境下运行的。
在点击finish后就进入了config状态了,该过程会从外网上下载对应的文件,有的文件会因为下载太慢或连接不稳定导致卡住。
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第2张图片

3.config中间可能遇到的问题

(1)卡在Downloading opencv_ffmpeg64.dll…

参考链接:https://blog.csdn.net/qq_38880380/article/details/78013056

解决方法:
可以直接使用下方的下载连接进行opencv_ffmpeg64.dll的下载
https://raw.githubusercontent.com/opencv/opencv_3rdparty/2a19d0006415955c79431116e4634f04d5eb5a74/ffmpeg/opencv_ffmpeg64.dll.
下载之后将此dll文件复制到之前下载的opencv_3.2.0下的某一路径中,并替换,具体如下
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第3张图片

(2)卡在Downloading ippicv_windows_20151201.zip

同样使用下方链接进行zip文件的下载
https://raw.githubusercontent.com/opencv/opencv_3rdparty/81a676001ca8075ada498583e4166079e5744668/ippicv/ippicv_windows_20151201.zip.
下载后对opencv-3.2.0\3rdparty\ippicv\downloads\windows-04e81ce5d0e329c3fbc606ae32cad44d\ippicv_windows_20151201.zip进行替换
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第4张图片

4.编译成功后

编译成功后会出现configuring done的字样
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第5张图片

5.添加扩展模块

在红色区域内找到OPENCV_EXTRA_MODUALS_PATH选项,选择自己下载解压后的opencv_contrib-3.2.0下的modules文件夹
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第6张图片

6.加入CMAKE_DEBUG_POSTFIX

点击add Entry,添加CMAKE_DEBUG_POSTFIX选项,设置为d,用于区分debug和release版本,否则编译安装时debug版本会被release版本覆盖。
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第7张图片
然后,可以通过CMAKE_INSTALL_PREFIX设置编译的库的输出目录,默认输出目录为D:/OpenCV/OpenCV3.2.0-vc12/build64/install
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第8张图片

7.再次点击config

此时会自动从外网下载一些文件,需要一些时间但并没有卡住,最后成功config
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第9张图片

8.点击generate

VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第10张图片
此时会在build的文件中生成如下文件
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第11张图片

9.点击OpenCV.sln文件

在生成的build64文件中找到OpenCV.sln,双击打开
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第12张图片

10.生成install文件

VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第13张图片
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第14张图片
点击生成后会进入编译状态,大概需要编译10分钟左右,
成功后生成一个install文件,注意此时编译后的结果中只有debug模式的结果,可以在debug模式下编译后再将模式调为release模式编译,这样生成的install文件中就即有debug的lib文件又有release的lib文件了。
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第15张图片
install文件中的内容如下
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第16张图片
VS2013+OpenCV3.2.0+OpenCV_contrib3.2.0编译过程_第17张图片

11.此时可以进行属性配置等操作了

可参考链接https://blog.csdn.net/cosmispower/article/details/60601151

属性配置中需要添加的lib
在debug模式下

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

载release模式下

opencv_aruco320.lib
opencv_bgsegm320.lib
opencv_bioinspired320.lib
opencv_calib3d320.lib
opencv_ccalib320.lib
opencv_core320.lib
opencv_datasets320.lib
opencv_dnn320.lib
opencv_dpm320.lib
opencv_face320.lib
opencv_features2d320.lib
opencv_flann320.lib
opencv_fuzzy320.lib
opencv_highgui320.lib
opencv_imgcodecs320.lib
opencv_imgproc320.lib
opencv_line_descriptor320.lib
opencv_ml320.lib
opencv_objdetect320.lib
opencv_optflow320.lib
opencv_phase_unwrapping320.lib
opencv_photo320.lib
opencv_plot320.lib
opencv_reg320.lib
opencv_rgbd320.lib
opencv_saliency320.lib
opencv_shape320.lib
opencv_stereo320.lib
opencv_stitching320.lib
opencv_structured_light320.lib
opencv_superres320.lib
opencv_surface_matching320.lib
opencv_text320.lib
opencv_tracking320.lib
opencv_video320.lib
opencv_videoio320.lib
opencv_videostab320.lib
opencv_xfeatures2d320.lib
opencv_ximgproc320.lib
opencv_xobjdetect320.lib
opencv_xobjdetect320.lib

编译后的文件

此时编译成功的文件可以在VS2013上的X64的debug或release模式下使用了
编译后的资源链接:
https://download.csdn.net/download/qq_44870829/13087504.

你可能感兴趣的:(opencv)