opencv---之如何安装opencv和opencv_contrib

概览

在 Ubuntu 类系统上安装 OpenCV 可以直接使用 apt 进行安装,直接在终端键入以下命令即可:

$ sudo apt install libopencv-dev

    1

如果只是使用 OpenCV 的基本功能,那么上面的安装方法非常简单快捷。但是如果要使用一些额外的算法,比如人脸识别,那就需要安装 opencv_contrib 来实现。本文记录了从源码安装 OpenCV 以及 opencv_contrib 的方法。

从源码安装 OpenCV 的基本流程如下:

    安装相关的依赖项
    下载 OpenCV 源码以及 opencv_contirb 源码
    配置编译环境
    编译安装

系统环境

ARMBIAN 5.38 stable Ubuntu 16.04.3 LTS 3.4.113-sun8i, Ubuntu 类系统都可以按照该方法进行安装。
安装步骤
1. 安装依赖项以及编译环境

sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

 

2. 下载 OpenCV 以及 opencv_conrib 源码

wget -O opencv-3.3.0.zip https://github.com/Itseez/opencv/archive/3.3.0.zip
wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.2.0.zip
unzip opencv-3.3.0.zip
unzip opencv_contrib.zip
cd opencv-3.3.0

 

3. 编译及安装

mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_C_EXAMPLES=OFF \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D OPENCV_EXTRA_MODULES_PATH= \
    -D BUILD_EXAMPLES=ON \
    -D ENABLE_NEON=ON ..

 

运行以下命令进行编译:

make -j4

    1

编译的时间和具体的硬件环境有很大的关系,在 Orange Pi 这样的嵌入式设备上需要一个小时以上,在 PC 上编译速度较快。
编译完成后执行

sudo make install

 

注:cmake报错

ffmeg/.... .h not found

或者什么什么包没有找到,重新建立一个干净的build再cmake一次
---------------------  
作者:echo42  
来源:CSDN  
原文:https://blog.csdn.net/echo42/article/details/80614470  
版权声明:本文为博主原创文章,转载请附上博文链接!

还有个错误 就是ubuntu装opencv error: ‘NppiGraphcutState‘ has not been declared

opencv---之如何安装opencv和opencv_contrib_第1张图片

 ubuntu下安装opencv3.2出现-- ICV: Downloading ippicv_linux_20151201.tgz...

之后就会提示很多错误。

需要自己下载ippicv_linux_20151201.tgz点击打开链接

然后复制替换到opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e文件下
---------------------  
作者:fjx812  
来源:CSDN  
原文:https://blog.csdn.net/fjx812/article/details/54946021  
版权声明:本文为博主原创文章,转载请附上博文链接!

 

2  no such directory hdf5:

解决方法:

https://github.com/opencv/opencv/issues/6016

 

 

遇到的报错

[ 98%] Building CXX object modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o
In file included from /home/epinux/dev/opencv_contrib/modules/tracking/include/opencv2/tracking/tracker.hpp:48:0,
                 from /home/epinux/dev/opencv/build2/modules/python2/pyopencv_generated_include.h:50,
                 from /home/epinux/dev/opencv/modules/python/src2/cv2.cpp:12:
/home/epinux/dev/opencv_contrib/modules/tracking/include/opencv2/tracking/onlineMIL.hpp:57:23: error: expected unqualified-id before ‘>’ token
 #define  sign(s)  ((s > 0 ) ? 1 : ((s<0) ? -1 : 0))
                       ^
/home/epinux/dev/opencv_contrib/modules/tracking/include/opencv2/tracking/onlineMIL.hpp:57:23: error: expected ‘)’ before ‘>’ token
/home/epinux/dev/opencv_contrib/modules/tracking/include/opencv2/tracking/onlineMIL.hpp:57:23: error: expected ‘)’ before ‘>’ token
modules/python2/CMakeFiles/opencv_python2.dir/build.make:296: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o' failed
make[2]: *** [modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o] Error 1
CMakeFiles/Makefile2:13133: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/all' failed
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

 

解决方案:

# 打开问题文件
gedit ~/opencv_contrib/modules/tracking/include/opencv2/tracking/onlineMIL.hpp

# 修改代码
# 找到下面这一行
#define sign(a) a > 0 ? 1 : a == 0 ? 0 : -1

替换为
namespace {
    template
    CV_INLINE int sign(const T v) {
        return (v > 0) ? 1 : ((v < 0) ? -1 : 0);
    }
} // anon namespace


# 然后重新
make -j8
sudo make install -j8
 
---------------------  
作者:_Lucask  
来源:CSDN  
原文:https://blog.csdn.net/qq_28413479/article/details/79805513  
版权声明:本文为博主原创文章,转载请附上博文链接!

 

/usr/bin/ld: 找不到 -lippicv

解决方案三:

从opencv.pc中可以看出,pkg-config加载库的路径是/usr/local/lib,我们去这这个路径下看看,发现没有-lippicv对应的库,别的选项都有对应的库,然后我们把-lippicv对应的库(libippicv.a)放到这个路径下就好啦了。
我的liboppicv.a在/home/ds/opencv-3.1.0/3rdparty/ippicv/unpack/ippicv_lnx/lib/intel64这个路径下。你的也在你自己opencv文件夹的对应路径下。
先cd 到上面这个路径下,然后cp liboppicv.a /usr/local/lib 将这个库文件复制到/usr/local/lib下就好了。

再试试,发现“/usr/bin/ld: 找不到 -lippicv
collect2: error: ld returned 1 exit status”这个错误已经解决。
---------------------  
作者:dengshuai_super  
来源:CSDN  
原文:https://blog.csdn.net/dengshuai_super/article/details/51895120  
版权声明:本文为博主原创文章,转载请附上博文链接!

 

opencv3.1.0,seletROI,按键没有反应space or enter

 key = key &0xFF

而不是key_

opencv---之如何安装opencv和opencv_contrib_第2张图片

cuda9与opencv3.1版本出错不匹配解决,cuda9不再支持2.0架构(cmake时):

使用Cmake编译opencv源码遇到如下错误

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
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

原因解析:

cuda9不再支持2.0架构


解决方案如下:

1).找到FindCUDA.cmake文件

找到行

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)


4).找到文件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")
      ...


5).cuda9中有一个单独的halffloat(cuda_fp16.h)头文件,也应该被包括在opencv的目录里

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

即在common.hpp中添加

#include

重新生成即可  
---------------------  
作者:Kmiracler  
来源:CSDN  
原文:https://blog.csdn.net/u014613745/article/details/78310916  
版权声明:本文为博主原创文章,转载请附上博文链接!

cuda9.0原因导致的(make时):

我的cuda版本是9.0,估计就是版本问题,网上有人说把cuda降到8.0以下。这个方法真是扯淡~

其实只要在编译的时候加一句话就好了

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler ..

关键就是在最后指定使用Kepler

 
---------------------  
作者:HandsomeHans  
来源:CSDN  
原文:https://blog.csdn.net/renhanchi/article/details/80493232  
版权声明:本文为博主原创文章,转载请附上博文链接!

你可能感兴趣的:(Linux学习笔记)