OpenCV编译出现 CMake Error: CUDA_nppi_LIBRARY (ADVANCED)

由于先安装了Cuda,再对OpenCV进行编译安装时,出现错误

OpenCV编译出现 CMake Error: CUDA_nppi_LIBRARY (ADVANCED)_第1张图片

具体内容如下:

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 /home/zqzy/software/opencv-3.2.0/modules/cudev
    linked by target "opencv_cudev" in directory /home/zqzy/software/opencv-3.2.0/modules/cudev
    linked by target "opencv_test_cudev" in directory /home/zqzy/software/opencv-3.2.0/modules/cudev/test
    linked by target "opencv_core" in directory /home/zqzy/software/opencv-3.2.0/modules/core
    linked by target "opencv_core" in directory /home/zqzy/software/opencv-3.2.0/modules/core
    linked by target "opencv_test_core" in directory /home/zqzy/software/opencv-3.2.0/modules/core
    linked by target "opencv_perf_core" in directory /home/zqzy/software/opencv-3.2.0/modules/core
    linked by target "opencv_perf_cudaarithm" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaarithm
    linked by target "opencv_test_cudaarithm" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaarithm
    linked by target "opencv_cudaarithm" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaarithm
    linked by target "opencv_cudaarithm" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaarithm
    linked by target "opencv_test_flann" in directory /home/zqzy/software/opencv-3.2.0/modules/flann
    linked by target "opencv_flann" in directory /home/zqzy/software/opencv-3.2.0/modules/flann
    linked by target "opencv_flann" in directory /home/zqzy/software/opencv-3.2.0/modules/flann
    linked by target "opencv_imgproc" in directory /home/zqzy/software/opencv-3.2.0/modules/imgproc
    linked by target "opencv_imgproc" in directory /home/zqzy/software/opencv-3.2.0/modules/imgproc
    linked by target "opencv_test_imgproc" in directory /home/zqzy/software/opencv-3.2.0/modules/imgproc
    linked by target "opencv_perf_imgproc" in directory /home/zqzy/software/opencv-3.2.0/modules/imgproc
    linked by target "opencv_test_ml" in directory /home/zqzy/software/opencv-3.2.0/modules/ml
    linked by target "opencv_ml" in directory /home/zqzy/software/opencv-3.2.0/modules/ml
    linked by target "opencv_ml" in directory /home/zqzy/software/opencv-3.2.0/modules/ml
    linked by target "opencv_video" in directory /home/zqzy/software/opencv-3.2.0/modules/video
    linked by target "opencv_video" in directory /home/zqzy/software/opencv-3.2.0/modules/video
    linked by target "opencv_test_video" in directory /home/zqzy/software/opencv-3.2.0/modules/video
    linked by target "opencv_perf_video" in directory /home/zqzy/software/opencv-3.2.0/modules/video
    linked by target "opencv_test_viz" in directory /home/zqzy/software/opencv-3.2.0/modules/viz
    linked by target "opencv_viz" in directory /home/zqzy/software/opencv-3.2.0/modules/viz
    linked by target "opencv_viz" in directory /home/zqzy/software/opencv-3.2.0/modules/viz
    linked by target "opencv_test_cudabgsegm" in directory /home/zqzy/software/opencv-3.2.0/modules/cudabgsegm
    linked by target "opencv_cudabgsegm" in directory /home/zqzy/software/opencv-3.2.0/modules/cudabgsegm
    linked by target "opencv_cudabgsegm" in directory /home/zqzy/software/opencv-3.2.0/modules/cudabgsegm
    linked by target "opencv_perf_cudabgsegm" in directory /home/zqzy/software/opencv-3.2.0/modules/cudabgsegm
    linked by target "opencv_test_cudafilters" in directory /home/zqzy/software/opencv-3.2.0/modules/cudafilters
    linked by target "opencv_cudafilters" in directory /home/zqzy/software/opencv-3.2.0/modules/cudafilters
    linked by target "opencv_cudafilters" in directory /home/zqzy/software/opencv-3.2.0/modules/cudafilters
    linked by target "opencv_perf_cudafilters" in directory /home/zqzy/software/opencv-3.2.0/modules/cudafilters
    linked by target "opencv_test_cudaimgproc" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaimgproc
    linked by target "opencv_perf_cudaimgproc" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaimgproc
    linked by target "opencv_cudaimgproc" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaimgproc
    linked by target "opencv_cudaimgproc" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaimgproc
    linked by target "opencv_test_cudawarping" in directory /home/zqzy/software/opencv-3.2.0/modules/cudawarping
    linked by target "opencv_cudawarping" in directory /home/zqzy/software/opencv-3.2.0/modules/cudawarping
    linked by target "opencv_cudawarping" in directory /home/zqzy/software/opencv-3.2.0/modules/cudawarping
    linked by target "opencv_perf_cudawarping" in directory /home/zqzy/software/opencv-3.2.0/modules/cudawarping
    linked by target "opencv_test_imgcodecs" in directory /home/zqzy/software/opencv-3.2.0/modules/imgcodecs
    linked by target "opencv_imgcodecs" in directory /home/zqzy/software/opencv-3.2.0/modules/imgcodecs
    linked by target "opencv_imgcodecs" in directory /home/zqzy/software/opencv-3.2.0/modules/imgcodecs
    linked by target "opencv_perf_imgcodecs" in directory /home/zqzy/software/opencv-3.2.0/modules/imgcodecs
    linked by target "opencv_test_photo" in directory /home/zqzy/software/opencv-3.2.0/modules/photo
    linked by target "opencv_photo" in directory /home/zqzy/software/opencv-3.2.0/modules/photo
    linked by target "opencv_photo" in directory /home/zqzy/software/opencv-3.2.0/modules/photo
    linked by target "opencv_perf_photo" in directory /home/zqzy/software/opencv-3.2.0/modules/photo
    linked by target "opencv_test_shape" in directory /home/zqzy/software/opencv-3.2.0/modules/shape
    linked by target "opencv_shape" in directory /home/zqzy/software/opencv-3.2.0/modules/shape
    linked by target "opencv_shape" in directory /home/zqzy/software/opencv-3.2.0/modules/shape
    linked by target "opencv_test_videoio" in directory /home/zqzy/software/opencv-3.2.0/modules/videoio
    linked by target "opencv_videoio" in directory /home/zqzy/software/opencv-3.2.0/modules/videoio
    linked by target "opencv_videoio" in directory /home/zqzy/software/opencv-3.2.0/modules/videoio
    linked by target "opencv_perf_videoio" in directory /home/zqzy/software/opencv-3.2.0/modules/videoio
    linked by target "opencv_test_cudacodec" in directory /home/zqzy/software/opencv-3.2.0/modules/cudacodec
    linked by target "opencv_cudacodec" in directory /home/zqzy/software/opencv-3.2.0/modules/cudacodec
    linked by target "opencv_cudacodec" in directory /home/zqzy/software/opencv-3.2.0/modules/cudacodec
    linked by target "opencv_perf_cudacodec" in directory /home/zqzy/software/opencv-3.2.0/modules/cudacodec
    linked by target "opencv_test_highgui" in directory /home/zqzy/software/opencv-3.2.0/modules/highgui
    linked by target "opencv_highgui" in directory /home/zqzy/software/opencv-3.2.0/modules/highgui
    linked by target "opencv_highgui" in directory /home/zqzy/software/opencv-3.2.0/modules/highgui
    linked by target "opencv_test_objdetect" in directory /home/zqzy/software/opencv-3.2.0/modules/objdetect
    linked by target "opencv_objdetect" in directory /home/zqzy/software/opencv-3.2.0/modules/objdetect
    linked by target "opencv_objdetect" in directory /home/zqzy/software/opencv-3.2.0/modules/objdetect
    linked by target "opencv_perf_objdetect" in directory /home/zqzy/software/opencv-3.2.0/modules/objdetect
    linked by target "opencv_ts" in directory /home/zqzy/software/opencv-3.2.0/modules/ts
    linked by target "opencv_ts" in directory /home/zqzy/software/opencv-3.2.0/modules/ts
    linked by target "opencv_test_features2d" in directory /home/zqzy/software/opencv-3.2.0/modules/features2d
    linked by target "opencv_features2d" in directory /home/zqzy/software/opencv-3.2.0/modules/features2d
    linked by target "opencv_features2d" in directory /home/zqzy/software/opencv-3.2.0/modules/features2d
    linked by target "opencv_perf_features2d" in directory /home/zqzy/software/opencv-3.2.0/modules/features2d
    linked by target "opencv_test_calib3d" in directory /home/zqzy/software/opencv-3.2.0/modules/calib3d
    linked by target "opencv_calib3d" in directory /home/zqzy/software/opencv-3.2.0/modules/calib3d
    linked by target "opencv_calib3d" in directory /home/zqzy/software/opencv-3.2.0/modules/calib3d
    linked by target "opencv_perf_calib3d" in directory /home/zqzy/software/opencv-3.2.0/modules/calib3d
    linked by target "opencv_test_cudafeatures2d" in directory /home/zqzy/software/opencv-3.2.0/modules/cudafeatures2d
    linked by target "opencv_perf_cudafeatures2d" in directory /home/zqzy/software/opencv-3.2.0/modules/cudafeatures2d
    linked by target "opencv_cudafeatures2d" in directory /home/zqzy/software/opencv-3.2.0/modules/cudafeatures2d
    linked by target "opencv_cudafeatures2d" in directory /home/zqzy/software/opencv-3.2.0/modules/cudafeatures2d
    linked by target "opencv_test_cudalegacy" in directory /home/zqzy/software/opencv-3.2.0/modules/cudalegacy
    linked by target "opencv_cudalegacy" in directory /home/zqzy/software/opencv-3.2.0/modules/cudalegacy
    linked by target "opencv_cudalegacy" in directory /home/zqzy/software/opencv-3.2.0/modules/cudalegacy
    linked by target "opencv_perf_cudalegacy" in directory /home/zqzy/software/opencv-3.2.0/modules/cudalegacy
    linked by target "opencv_test_cudaobjdetect" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaobjdetect
    linked by target "opencv_cudaobjdetect" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaobjdetect
    linked by target "opencv_cudaobjdetect" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaobjdetect
    linked by target "opencv_perf_cudaobjdetect" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaobjdetect
    linked by target "opencv_test_cudaoptflow" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaoptflow
    linked by target "opencv_cudaoptflow" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaoptflow
    linked by target "opencv_cudaoptflow" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaoptflow
    linked by target "opencv_perf_cudaoptflow" in directory /home/zqzy/software/opencv-3.2.0/modules/cudaoptflow
    linked by target "opencv_test_cudastereo" in directory /home/zqzy/software/opencv-3.2.0/modules/cudastereo
    linked by target "opencv_perf_cudastereo" in directory /home/zqzy/software/opencv-3.2.0/modules/cudastereo
    linked by target "opencv_cudastereo" in directory /home/zqzy/software/opencv-3.2.0/modules/cudastereo
    linked by target "opencv_cudastereo" in directory /home/zqzy/software/opencv-3.2.0/modules/cudastereo
    linked by target "opencv_test_stitching" in directory /home/zqzy/software/opencv-3.2.0/modules/stitching
    linked by target "opencv_perf_stitching" in directory /home/zqzy/software/opencv-3.2.0/modules/stitching
    linked by target "opencv_stitching" in directory /home/zqzy/software/opencv-3.2.0/modules/stitching
    linked by target "opencv_stitching" in directory /home/zqzy/software/opencv-3.2.0/modules/stitching
    linked by target "opencv_superres" in directory /home/zqzy/software/opencv-3.2.0/modules/superres
    linked by target "opencv_superres" in directory /home/zqzy/software/opencv-3.2.0/modules/superres
    linked by target "opencv_test_superres" in directory /home/zqzy/software/opencv-3.2.0/modules/superres
    linked by target "opencv_perf_superres" in directory /home/zqzy/software/opencv-3.2.0/modules/superres
    linked by target "opencv_videostab" in directory /home/zqzy/software/opencv-3.2.0/modules/videostab
    linked by target "opencv_videostab" in directory /home/zqzy/software/opencv-3.2.0/modules/videostab
    linked by target "opencv_traincascade" in directory /home/zqzy/software/opencv-3.2.0/apps/traincascade
    linked by target "opencv_createsamples" in directory /home/zqzy/software/opencv-3.2.0/apps/createsamples
    linked by target "opencv_annotation" in directory /home/zqzy/software/opencv-3.2.0/apps/annotation
    linked by target "opencv_visualisation" in directory /home/zqzy/software/opencv-3.2.0/apps/visualisation
    linked by target "opencv_version" in directory /home/zqzy/software/opencv-3.2.0/apps/version

-- Configuring incomplete, errors occurred!
See also "/home/zqzy/software/opencv-3.2.0/build/CMakeFiles/CMakeOutput.log".
See also "/home/zqzy/software/opencv-3.2.0/build/CMakeFiles/CMakeError.log".

原因解析:

cuda9不再支持2.0架构

 

解决方法:

第一步:在  opencv-3.2.0/cmake  文件夹下找到  FindCUDA.cmake 文件,对其进行修改

cd /home/zqzy/software/opencv-3.2.0/cmake
sudo gedit FindCUDA.cmake

1)找到行

find_cuda_helper_libs(nppi)

改为

  find_cuda_helper_libs(nppial)
  find_cuda_helper_libs(nppicc)
  find_cuda_helper_libs(nppicom)
  find_cuda_helper_libs(nppidei)
  find_cuda_helper_libs(nppif)
  find_cuda_helper_libs(nppig)
  find_cuda_helper_libs(nppim)
  find_cuda_helper_libs(nppist)
  find_cuda_helper_libs(nppisu)
  find_cuda_helper_libs(nppitc)

2)找到行

set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}")

改为

set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}")

3)找到行

unset(CUDA_nppi_LIBRARY CACHE)

改为

unset(CUDA_nppial_LIBRARY CACHE)
unset(CUDA_nppicc_LIBRARY CACHE)
unset(CUDA_nppicom_LIBRARY CACHE)
unset(CUDA_nppidei_LIBRARY CACHE)
unset(CUDA_nppif_LIBRARY CACHE)
unset(CUDA_nppig_LIBRARY CACHE)
unset(CUDA_nppim_LIBRARY CACHE)
unset(CUDA_nppist_LIBRARY CACHE)
unset(CUDA_nppisu_LIBRARY CACHE)
unset(CUDA_nppitc_LIBRARY CACHE)

第二步:  在  opencv-3.2.0/cmake  文件夹下找到文件  OpenCVDetectCUDA.cmake,对其进行修改

cd /home/zqzy/software/opencv-3.2.0/cmake

sudo gedit OpenCVDetectCUDA.cmake

  修改以下几行

 ...
  set(__cuda_arch_ptx "")
  if(CUDA_GENERATION STREQUAL "Fermi")
    set(__cuda_arch_bin "2.0")
  elseif(CUDA_GENERATION STREQUAL "Kepler")
    set(__cuda_arch_bin "3.0 3.5 3.7")
  ...

改为

  ...
  set(__cuda_arch_ptx "")
  if(CUDA_GENERATION STREQUAL "Kepler")
    set(__cuda_arch_bin "3.0 3.5 3.7")
  elseif(CUDA_GENERATION STREQUAL "Maxwell")
    set(__cuda_arch_bin "5.0 5.2")
  ...

第三步: Cuda9或者Cuda10及以后的版本 中有一个单独的halffloat(cuda_fp16.h)头文件,也应该被包括在opencv的目录里

将头文件cuda_fp16.h添加至 opencv/modules/cudev/include/opencv2/cudev/common.hpp

cd /home/zqzy/software/opencv-3.2.0/modules/cudev/include/opencv2/cudev

sudo gedit common.hpp

即在common.hpp中添加

#include 

重新生成即可 

 

参考:https://blog.csdn.net/u014613745/article/details/78310916

        https://blog.csdn.net/dawn_chen121/article/details/82828629

 

 

 

 

 

 

你可能感兴趣的:(三维重建,SLAM)