编译opencv2 包含CUDA功能 -- 编译错误

最近项目需要,需要实现视频拼接的功能。网上搜了好长时间,基本思路是利用opencv 的video stitch模块,实现视频拼接。

下面我把编译opencv的过程写一下,过程比较曲折,现在把有歧义的部分记录一下。

我们需要用到的东西opencv3.2,CUDA, TBB。简单说一下这三者的作用,对比如下。

  • OpenCV是一组编程模块,可帮助我们轻松完成复杂的实时计算机视觉任务。由于其可靠性和开源理念,它一直是最受欢迎的计算机视觉工具之一
  • CUDA是一个并行计算工具包,它允许我们使用NVidia GPU的强大功能来显着提高应用程序的性能。

James Bowley发布了详细的性能比较,您可以在其中看到CUDA对OpenCV的影响(链接地址)

  • TBB是intel用标准c++写的一个开源的并行计算库。它的目的是提升数据并行计算的能力,可以在他的官网上下载最新的库和文档。TBB主要功能:

    1. 并行算法
    2. 任务调度
    3. 并行容器
    4. 同步原语
    5. 内存分配器

我安装的是CUDA10.2的版本,产生两个安装目录

C:\ProgramData\NVIDIA Corporation\CUDA Samples\v10.2

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2          

opencv 有2.0、3.0d 的版本区分。CUDA也有很多版本,比如我安装的就是CUDA10.2。由于我的电脑比较旧,一直用的是vs2013的IDE。所以需要下载包含VC12的库。opencv 我使用的是3.2的版本,其实大版本还是属于opencv2。我知道的由于从CUDA9.0开始不再支持opencv2(某些写法调用会有变化,直接编译会导致失败。)会产生编译错误如下

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppi_LIBRARY (ADVANCED)
linked by target "opencv_cudev" in directory D:/Cproject/opencv/opencv/sources/modules/cudev
linked by target "opencv_cudev" in directory D:/Cproject/opencv/opencv/sources/modules/cudev
linked by target "opencv_test_cudev" in directory D:/Cproject/opencv/opencv/sources/modules/cudev/test
linked by target "opencv_core" in directory D:/Cproject/opencv/opencv/sources/modules/core
linked by target "opencv_core" in directory D:/Cproject/opencv/opencv/sources/modules/core
linked by target "opencv_test_core" in directory D:/Cproject/opencv/opencv/sources/modules/core
linked by target "opencv_perf_core" in directory D:/Cproject/opencv/opencv/sources/modules/core
linked by target "opencv_test_cudaarithm" in directory D:/Cproject/opencv/opencv/sources/modules/cudaarithm
linked by target "opencv_cudaarithm" in directory D:/Cproject/opencv/opencv/sources/modules/cudaarithm
linked by target "opencv_cudaarithm" in directory D:/Cproject/opencv/opencv/sources/modules/cudaarithm
linked by target "opencv_perf_cudaarithm" in directory D:/Cproject/opencv/opencv/sources/modules/cudaarithm
linked by target "opencv_flann" in directory D:/Cproject/opencv/opencv/sources/modules/flann
linked by target "opencv_flann" in directory D:/Cproject/opencv/opencv/sources/modules/flann
linked by target "opencv_test_flann" in directory D:/Cproject/opencv/opencv/sources/modules/flann
linked by target "opencv_imgproc" in directory D:/Cproject/opencv/opencv/sources/modules/imgproc
linked by target "opencv_imgproc" in directory D:/Cproject/opencv/opencv/sources/modules/imgproc
linked by target "opencv_test_imgproc" in directory D:/Cproject/opencv/opencv/sources/modules/imgproc
linked by target "opencv_perf_imgproc" in directory D:/Cproject/opencv/opencv/sources/modules/imgproc
linked by target "opencv_test_ml" in directory D:/Cproject/opencv/opencv/sources/modules/ml
linked by target "opencv_ml" in directory D:/Cproject/opencv/opencv/sources/modules/ml
linked by target "opencv_ml" in directory D:/Cproject/opencv/opencv/sources/modules/ml
linked by target "opencv_test_video" in directory D:/Cproject/opencv/opencv/sources/modules/video
linked by target "opencv_video" in directory D:/Cproject/opencv/opencv/sources/modules/video
linked by target "opencv_video" in directory D:/Cproject/opencv/opencv/sources/modules/video
linked by target "opencv_perf_video" in directory D:/Cproject/opencv/opencv/sources/modules/video
linked by target "opencv_cudabgsegm" in directory D:/Cproject/opencv/opencv/sources/modules/cudabgsegm
linked by target "opencv_cudabgsegm" in directory D:/Cproject/opencv/opencv/sources/modules/cudabgsegm
linked by target "opencv_test_cudabgsegm" in directory D:/Cproject/opencv/opencv/sources/modules/cudabgsegm
linked by target "opencv_perf_cudabgsegm" in directory D:/Cproject/opencv/opencv/sources/modules/cudabgsegm
linked by target "opencv_cudafilters" in directory D:/Cproject/opencv/opencv/sources/modules/cudafilters
linked by target "opencv_cudafilters" in directory D:/Cproject/opencv/opencv/sources/modules/cudafilters
linked by target "opencv_test_cudafilters" in directory D:/Cproject/opencv/opencv/sources/modules/cudafilters
linked by target "opencv_perf_cudafilters" in directory D:/Cproject/opencv/opencv/sources/modules/cudafilters
linked by target "opencv_cudaimgproc" in directory D:/Cproject/opencv/opencv/sources/modules/cudaimgproc
linked by target "opencv_cudaimgproc" in directory D:/Cproject/opencv/opencv/sources/modules/cudaimgproc
linked by target "opencv_test_cudaimgproc" in directory D:/Cproject/opencv/opencv/sources/modules/cudaimgproc
linked by target "opencv_perf_cudaimgproc" in directory D:/Cproject/opencv/opencv/sources/modules/cudaimgproc
linked by target "opencv_perf_cudawarping" in directory D:/Cproject/opencv/opencv/sources/modules/cudawarping
linked by target "opencv_cudawarping" in directory D:/Cproject/opencv/opencv/sources/modules/cudawarping
linked by target "opencv_cudawarping" in directory D:/Cproject/opencv/opencv/sources/modules/cudawarping
linked by target "opencv_test_cudawarping" in directory D:/Cproject/opencv/opencv/sources/modules/cudawarping
linked by target "opencv_imgcodecs" in directory D:/Cproject/opencv/opencv/sources/modules/imgcodecs
linked by target "opencv_imgcodecs" in directory D:/Cproject/opencv/opencv/sources/modules/imgcodecs
linked by target "opencv_test_imgcodecs" in directory D:/Cproject/opencv/opencv/sources/modules/imgcodecs
linked by target "opencv_perf_imgcodecs" in directory D:/Cproject/opencv/opencv/sources/modules/imgcodecs
linked by target "opencv_perf_photo" in directory D:/Cproject/opencv/opencv/sources/modules/photo
linked by target "opencv_photo" in directory D:/Cproject/opencv/opencv/sources/modules/photo
linked by target "opencv_photo" in directory D:/Cproject/opencv/opencv/sources/modules/photo
linked by target "opencv_test_photo" in directory D:/Cproject/opencv/opencv/sources/modules/photo
linked by target "opencv_test_shape" in directory D:/Cproject/opencv/opencv/sources/modules/shape
linked by target "opencv_shape" in directory D:/Cproject/opencv/opencv/sources/modules/shape
linked by target "opencv_shape" in directory D:/Cproject/opencv/opencv/sources/modules/shape
linked by target "opencv_test_videoio" in directory D:/Cproject/opencv/opencv/sources/modules/videoio
linked by target "opencv_videoio" in directory D:/Cproject/opencv/opencv/sources/modules/videoio
linked by target "opencv_videoio" in directory D:/Cproject/opencv/opencv/sources/modules/videoio
linked by target "opencv_perf_videoio" in directory D:/Cproject/opencv/opencv/sources/modules/videoio
linked by target "opencv_cudacodec" in directory D:/Cproject/opencv/opencv/sources/modules/cudacodec
linked by target "opencv_cudacodec" in directory D:/Cproject/opencv/opencv/sources/modules/cudacodec
linked by target "opencv_perf_cudacodec" in directory D:/Cproject/opencv/opencv/sources/modules/cudacodec
linked by target "opencv_test_cudacodec" in directory D:/Cproject/opencv/opencv/sources/modules/cudacodec
linked by target "opencv_highgui" in directory D:/Cproject/opencv/opencv/sources/modules/highgui
linked by target "opencv_highgui" in directory D:/Cproject/opencv/opencv/sources/modules/highgui
linked by target "opencv_test_highgui" in directory D:/Cproject/opencv/opencv/sources/modules/highgui
linked by target "opencv_perf_objdetect" in directory D:/Cproject/opencv/opencv/sources/modules/objdetect
linked by target "opencv_objdetect" in directory D:/Cproject/opencv/opencv/sources/modules/objdetect
linked by target "opencv_objdetect" in directory D:/Cproject/opencv/opencv/sources/modules/objdetect
linked by target "opencv_test_objdetect" in directory D:/Cproject/opencv/opencv/sources/modules/objdetect
linked by target "opencv_ts" in directory D:/Cproject/opencv/opencv/sources/modules/ts
linked by target "opencv_ts" in directory D:/Cproject/opencv/opencv/sources/modules/ts
linked by target "opencv_test_features2d" in directory D:/Cproject/opencv/opencv/sources/modules/features2d
linked by target "opencv_features2d" in directory D:/Cproject/opencv/opencv/sources/modules/features2d
linked by target "opencv_features2d" in directory D:/Cproject/opencv/opencv/sources/modules/features2d
linked by target "opencv_perf_features2d" in directory D:/Cproject/opencv/opencv/sources/modules/features2d
linked by target "opencv_calib3d" in directory D:/Cproject/opencv/opencv/sources/modules/calib3d
linked by target "opencv_calib3d" in directory D:/Cproject/opencv/opencv/sources/modules/calib3d
linked by target "opencv_test_calib3d" in directory D:/Cproject/opencv/opencv/sources/modules/calib3d
linked by target "opencv_perf_calib3d" in directory D:/Cproject/opencv/opencv/sources/modules/calib3d
linked by target "opencv_cudafeatures2d" in directory D:/Cproject/opencv/opencv/sources/modules/cudafeatures2d
linked by target "opencv_cudafeatures2d" in directory D:/Cproject/opencv/opencv/sources/modules/cudafeatures2d
linked by target "opencv_test_cudafeatures2d" in directory D:/Cproject/opencv/opencv/sources/modules/cudafeatures2d
linked by target "opencv_perf_cudafeatures2d" in directory D:/Cproject/opencv/opencv/sources/modules/cudafeatures2d
linked by target "opencv_cudalegacy" in directory D:/Cproject/opencv/opencv/sources/modules/cudalegacy
linked by target "opencv_cudalegacy" in directory D:/Cproject/opencv/opencv/sources/modules/cudalegacy
linked by target "opencv_test_cudalegacy" in directory D:/Cproject/opencv/opencv/sources/modules/cudalegacy
linked by target "opencv_perf_cudalegacy" in directory D:/Cproject/opencv/opencv/sources/modules/cudalegacy
linked by target "opencv_cudaobjdetect" in directory D:/Cproject/opencv/opencv/sources/modules/cudaobjdetect
linked by target "opencv_cudaobjdetect" in directory D:/Cproject/opencv/opencv/sources/modules/cudaobjdetect
linked by target "opencv_perf_cudaobjdetect" in directory D:/Cproject/opencv/opencv/sources/modules/cudaobjdetect
linked by target "opencv_test_cudaobjdetect" in directory D:/Cproject/opencv/opencv/sources/modules/cudaobjdetect
linked by target "opencv_cudaoptflow" in directory D:/Cproject/opencv/opencv/sources/modules/cudaoptflow
linked by target "opencv_cudaoptflow" in directory D:/Cproject/opencv/opencv/sources/modules/cudaoptflow
linked by target "opencv_test_cudaoptflow" in directory D:/Cproject/opencv/opencv/sources/modules/cudaoptflow
linked by target "opencv_perf_cudaoptflow" in directory D:/Cproject/opencv/opencv/sources/modules/cudaoptflow
linked by target "opencv_perf_cudastereo" in directory D:/Cproject/opencv/opencv/sources/modules/cudastereo
linked by target "opencv_cudastereo" in directory D:/Cproject/opencv/opencv/sources/modules/cudastereo
linked by target "opencv_cudastereo" in directory D:/Cproject/opencv/opencv/sources/modules/cudastereo
linked by target "opencv_test_cudastereo" in directory D:/Cproject/opencv/opencv/sources/modules/cudastereo
linked by target "opencv_test_stitching" in directory D:/Cproject/opencv/opencv/sources/modules/stitching
linked by target "opencv_stitching" in directory D:/Cproject/opencv/opencv/sources/modules/stitching
linked by target "opencv_stitching" in directory D:/Cproject/opencv/opencv/sources/modules/stitching
linked by target "opencv_perf_stitching" in directory D:/Cproject/opencv/opencv/sources/modules/stitching
linked by target "opencv_superres" in directory D:/Cproject/opencv/opencv/sources/modules/superres
linked by target "opencv_superres" in directory D:/Cproject/opencv/opencv/sources/modules/superres
linked by target "opencv_test_superres" in directory D:/Cproject/opencv/opencv/sources/modules/superres
linked by target "opencv_perf_superres" in directory D:/Cproject/opencv/opencv/sources/modules/superres
linked by target "opencv_videostab" in directory D:/Cproject/opencv/opencv/sources/modules/videostab
linked by target "opencv_videostab" in directory D:/Cproject/opencv/opencv/sources/modules/videostab
linked by target "opencv_traincascade" in directory D:/Cproject/opencv/opencv/sources/apps/traincascade
linked by target "opencv_createsamples" in directory D:/Cproject/opencv/opencv/sources/apps/createsamples
linked by target "opencv_annotation" in directory D:/Cproject/opencv/opencv/sources/apps/annotation
linked by target "opencv_visualisation" in directory D:/Cproject/opencv/opencv/sources/apps/visualisation
linked by target "opencv_version" in directory D:/Cproject/opencv/opencv/sources/apps/version

 搜了一下,找到了解决办法,附上链接解决编译错误。

 

 

 

你可能感兴趣的:(opencv,CUDA,opencv,编译错误)