当前位置:   article > 正文

cmake编译opencv3:opencv3.3.1+contrib+cuda8.0+vs2013(2015)+cmake3.10.1_opencv 编译 cuda cmake

opencv 编译 cuda cmake

**
参考资料:https://www.learnopencv.com/install-opencv3-on-windows/

结尾有福利哦!

**

0前言

自从进入3.X时代以后,OpenCV将代码库分成了两部分,分别是稳定的核心功能库和试验性质的contrib库,而且从3.1以后,编译好的版本中就没有现成的x86平台的库了,只有x64,想用就必须自己从源码编译。
配置cuda是为了利用GPU的加速。

1安装所需文件

opencv:https://opencv.org/releases.html
opencv_contrb下载:
https://github.com/opencv/opencv_contrib/releases
tbb下载(仅用于配置cuda所需)(存放路径中不要有中文):
https://github.com/01org/tbb/releases

cuda之前安装好了(cuda8.0);

2cmake编译

1.打开Cmake

【Where is the source code】放的是OpenCV解压后的源代码
我的是 C:\Users\6Qiang\Downloads\opencv-3.3.1

【Where to build the linaries】放的是编译好的程序
我的是 C:\Users\6Qiang\Downloads\opencv-3.3.1\build
点击【Advanced】按照首字母排序
点击【Configure】之后会进入VS编译器的版本选择界面:

注意:

**Win64表示电脑是64位系统,不带64的表示电脑是Windows 32位系统,ARM表示芯片是ARM的电脑(如Visual Studio 14 2015 Win64)

2.第一次Configure

(第一次Configure一定要联网,编译过程中,会下载第三方依赖库ffmpeg以及ippicv)

  • contrib库的配置
    找到OPENCV_EXTRRA_MODULES_PATH项,后面添加opencv_contrib-3.3.1中的modules目录
    (如I:\软件\专业软件\opencv_contrib-3.3.1\modules)

  • WITH栏配置
    (WITH_CUDA,WITH_FFT,WITH_CUBLAS应该是默认选中的)
    选中WITH_EIGN,WITH_TBB

注意:

如果不编译cuda,则搜索所有包含cuda的项目,然后删掉其后面的信息,以免安装时出现错误。

3.第二次configure(不装cuda则忽略此步骤)

我下载的tbb放在了C:\Users\6Qiang\Downloads\tbb2018_20171205oss

注:此处tbb存放路径不要有中文,之前我一直编译错误后来发现都是这和中文路径惹的祸

  • TBB栏配置
    TBB_ENV_iNCLUDE: 添加tbb的include的目录
    (如C:\Users\6Qiang\Downloads\tbb2018_20171205oss\include)
    TBB_ENV_LIB: 添加tbb的tbb.lib文件
    (如C:\Users\6Qiang\Downloads\tbb2018_20171205oss\lib\intel64\vc12\tbb.lib)(VS2015就选vc14的目录
    TBB_ENV_LIB_DEBUG: 添加tbb的tbb_debug.lib文件
    (如C:\Users\6Qiang\Downloads\tbb2018_20171205oss\lib\intel64\vc12\tbb_debug.lib)(VS2015就选vc14的目录

4.第三次configure(不断configure直到最后没有红色为止)

TBB_VER_FILE:添加tbb_stddef.h的目录
(如C:\Users\6Qiang\Downloads\tbb2018_20171205oss\include\tbb\tbb_stddef.h)

5.generate

说明:Cmake中红色的部分说明还没有更新,需要点击Configure更新,每次更改完一些配置或者参数之后都要点击Configure更新一下。最后确定配置无误了再点Generate,将会在你的目标文件夹中生成项目文件。

6.generate后的显示

Configuring done
Generating done
  • 1
  • 2

3 VS编译

打开cmd,转到自己的编译后的目录(我的是C:\Users\6Qiang\Downloads\opencv-3.3.1\build),运行以下命令。

Release模式下编译:
cmake.exe --build . --config Release --target INSTALL
Debug模式下编译:
cmake.exe --build . --config Debug --target INSTALL
  • 1
  • 2
  • 3
  • 4

编译完成之后,你会在你的目标文件夹中找到一个install文件夹,里边就有Debug和Release的各种你需要的东西。(把install文件夹内容复制出来即可)

而没有cuda的编译,debug花了13分钟,release花了18分钟。
而加入cuda后的编译,debug、release各花了6个小时左右。

4编译体会

一共连续搞了5天的编译,按照网上的步骤一开始各种出错,后来参考国外博客的编译,成功了终于编译了十几个多小时,总结出了自己的编译步骤。

最后,编译成功了。(没有错误,带有cuda的一共有9万多个警告,都是些字符格式警告,不影响)

5vs中的配置

具体配置步骤参考我的另一片文章:http://blog.csdn.net/luqiang6q/article/details/78935105

Release版称为发行版,Debug版称为调试版。 Debug中可以单步执行、跟踪等功能,但生成的可执行文件比较大,代码运行速度较慢。Release版运行速度较快,可执行文件较小,但在其编译条件下无法执行调试功能。

我觉得先用release,遇到问题了再用debug,最后发布用release(release的速度比debug快很多)。

debug

opencv_aruco331d.lib
opencv_bgsegm331d.lib
opencv_bioinspired331d.lib
opencv_calib3d331d.lib
opencv_ccalib331d.lib
opencv_core331d.lib
opencv_cudaarithm331d.lib
opencv_cudabgsegm331d.lib
opencv_cudacodec331d.lib
opencv_cudafeatures2d331d.lib
opencv_cudafilters331d.lib
opencv_cudaimgproc331d.lib
opencv_cudalegacy331d.lib
opencv_cudaobjdetect331d.lib
opencv_cudaoptflow331d.lib
opencv_cudastereo331d.lib
opencv_cudawarping331d.lib
opencv_cudev331d.lib
opencv_datasets331d.lib
opencv_dnn331d.lib
opencv_dpm331d.lib
opencv_face331d.lib
opencv_features2d331d.lib
opencv_flann331d.lib
opencv_fuzzy331d.lib
opencv_hdf331d.lib
opencv_highgui331d.lib
opencv_imgcodecs331d.lib
opencv_imgproc331d.lib
opencv_img_hash331d.lib
opencv_line_descriptor331d.lib
opencv_ml331d.lib
opencv_objdetect331d.lib
opencv_optflow331d.lib
opencv_phase_unwrapping331d.lib
opencv_photo331d.lib
opencv_plot331d.lib
opencv_reg331d.lib
opencv_rgbd331d.lib
opencv_saliency331d.lib
opencv_shape331d.lib
opencv_stereo331d.lib
opencv_stitching331d.lib
opencv_structured_light331d.lib
opencv_superres331d.lib
opencv_surface_matching331d.lib
opencv_text331d.lib
opencv_tracking331d.lib
opencv_video331d.lib
opencv_videoio331d.lib
opencv_videostab331d.lib
opencv_viz331d.lib
opencv_xfeatures2d331d.lib
opencv_ximgproc331d.lib
opencv_xobjdetect331d.lib
opencv_xphoto331d.lib
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56

release

opencv_aruco331.lib
opencv_bgsegm331.lib
opencv_bioinspired331.lib
opencv_calib3d331.lib
opencv_ccalib331.lib
opencv_core331.lib
opencv_cudaarithm331.lib
opencv_cudabgsegm331.lib
opencv_cudacodec331.lib
opencv_cudafeatures2d331.lib
opencv_cudafilters331.lib
opencv_cudaimgproc331.lib
opencv_cudalegacy331.lib
opencv_cudaobjdetect331.lib
opencv_cudaoptflow331.lib
opencv_cudastereo331.lib
opencv_cudawarping331.lib
opencv_cudev331.lib
opencv_datasets331.lib
opencv_dnn331.lib
opencv_dpm331.lib
opencv_face331.lib
opencv_features2d331.lib
opencv_flann331.lib
opencv_fuzzy331.lib
opencv_hdf331.lib
opencv_highgui331.lib
opencv_imgcodecs331.lib
opencv_imgproc331.lib
opencv_img_hash331.lib
opencv_line_descriptor331.lib
opencv_ml331.lib
opencv_objdetect331.lib
opencv_optflow331.lib
opencv_phase_unwrapping331.lib
opencv_photo331.lib
opencv_plot331.lib
opencv_reg331.lib
opencv_rgbd331.lib
opencv_saliency331.lib
opencv_shape331.lib
opencv_stereo331.lib
opencv_stitching331.lib
opencv_structured_light331.lib
opencv_superres331.lib
opencv_surface_matching331.lib
opencv_text331.lib
opencv_tracking331.lib
opencv_video331.lib
opencv_videoio331.lib
opencv_videostab331.lib
opencv_viz331.lib
opencv_xfeatures2d331.lib
opencv_ximgproc331.lib
opencv_xobjdetect331.lib
opencv_xphoto331.lib
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56

6最后需要把下载的tbb文件夹中的tbb.dll和tbb_debug.dll放到opencv的x64\vc12\bin目录下(否则可能出现缺少这两种文件的错误)

我的在C:\Users\6Qiang\Downloads\tbb2018_20171205oss\bin\intel64\vc12下面

附上自己已经编译好的资源链接:http://download.csdn.net/download/luqiang6q/10180887

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/132716
推荐阅读
相关标签
  

闽ICP备14008679号