在CUDA8.0下指定位置编译安装OpenCV3.1.0来实现GPU加速(Compiling OpenCV3.1.0 with CUDA8.0 support)

在CUDA8.0下指定位置编译安装OpenCV3.1.0

一、本人电脑配置:ubuntu 14.04, NVIDIA GTX1060。

二、编译OpenCV3.1.0前,读者需要成功安装CUDA8.0(网上有相关教程)。

三、在CUDA8.0下编译安装OpenCV3.1.0。

1. 安装依赖库

. sudo apt-get update
. sudo apt-get install libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394--dev libxine-dev libgstreamer0.-dev libgstreamer-plugins-base0.-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils
. sudo add-apt-repository ppa:jon-severinsson/ffmpeg
. sudo apt-get update
. sudo apt-get install ffmpeg
. sudo apt-get install frei0r-plugins

2. 下载OpenCV资源

在OpenCV官网:https://opencv.org/releases.html,选择3.1.0,点击Source,下载opencv-3.1.0源码文件夹。

本人将opencv-3.1.0文件夹放置到 /home/yuanlibin目录下。

3. 编译安装

. cd opencv-3.1.
. mkdir build
. cd build
. cmake \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr/local/opencv_3.1.0 \
-D WITH_CUDA=ON \
-D WITH_CUBLAS=ON \
-D CUDA_FAST_MATH=ON \
-D WITH_CUFFT=ON \
-D WITH_NVCUVID=ON \
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON \
-D WITH_OPENGL=ON \
-D WITH_FFMPEG=ON \
-D INSTALL_C_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
..

编译出现错误(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_nvcuvid_LIBRARY (ADVANCED)
linked by target "opencv_cudacodec" in directory /home/yuanlibin/opencv-3.1./modules/cudacodec -- Configuring incomplete, errors occurred!
See also "/home/yuanlibin/opencv-3.1.0/build/CMakeFiles/CMakeOutput.log".
See also "/home/yuanlibin/opencv-3.1.0/build/CMakeFiles/CMakeError.log".

解决方法:https://askubuntu.com/questions/691889/opencv-with-cuda-on-ubuntu-14-04-installation-error/691931#691931?newreg=470a4d740d374683be7b530f5df59393

The problem was the missing libnvcuvid library which could be solved with the two following commands:

. sudo ln -s /usr/lib/nvidia-/libnvcuvid.so /usr/lib/libnvcuvid.so
. sudo ln -s /usr/lib/nvidia-/libnvcuvid.so. /usr/lib/libnvcuvid.so.

This solves the cmake error and afterwards allows to use the cuda video codec with opencv.
(说明:ln是linux中一个非常重要命令。它的功能是为某一个文件在另外一个位置建立一个同步的软链接,这个命令最常用的参数是-s,具体用法是:ln -s 源文件路径 目标文件路径。)

再次编译之后,终端显示如下:

……
Parallel framework: pthreads
--
-- Other third-party libraries:
-- Use IPP: 9.0. [9.0.]
-- at: /home/yuanlibin/opencv-3.1./3rdparty/ippicv/unpack/ippicv_lnx
-- Use IPP Async: NO
-- Use VA: NO
-- Use Intel VA-API/OpenCL: NO
-- Use Eigen: YES (ver 3.2.)
-- Use Cuda: YES (ver 8.0)
-- Use OpenCL: YES
-- Use custom HAL: NO
--
-- NVIDIA CUDA
-- Use CUFFT: YES
-- Use CUBLAS: YES
-- USE NVCUVID: YES
-- NVIDIA GPU arch:
-- NVIDIA PTX archs:
-- Use fast math: YES
……

然后执行以下命令:

. make -j4

编译出现错误(2)如下:

[ %] Building CXX object modules/cudacodec/CMakeFiles/opencv_cudacodec.dir/src/video_reader.cpp.o
make[]: *** No rule to make target `/usr/lib/libnvcuvid.so', needed by `lib/libopencv_cudacodec.so.3.1.0'. Stop.
make[]: *** Waiting for unfinished jobs....
[ %] Building CXX object modules/cudacodec/CMakeFiles/opencv_cudacodec.dir/src/cuvid_video_source.cpp.o
make[]: *** [modules/cudacodec/CMakeFiles/opencv_cudacodec.dir/all] Error
make[]: *** Waiting for unfinished jobs....
Scanning dependencies of target opencv_cudafilters
[ %] Building CXX object modules/cudafilters/CMakeFiles/opencv_cudafilters.dir/src/filtering.cpp.o
Linking CXX shared library ../../lib/libopencv_cudafilters.so
[ %] Built target opencv_cudafilters
make: *** [all] Error
yuanlibin@yuanlibin:~/opencv-3.1./build$

解决方法:http://answers.opencv.org/question/41575/no-rule-to-make-target-usrliblibnvcuvidso-needed-by-liblibopencv_gpuso2/

Find out where libnvcuvid.so is located and create a softlink to it:

. locate libnvcuvid.so
. sudo ln -s /path/to/found/libnvcuvid.so /usr/lib/libnvcuvid.so

locate命令找到相应的路径。

yuanlibin@yuanlibin:~/opencv-3.1./build$ locate libnvcuvid.so
/usr/lib/nvidia-/libnvcuvid.so
/usr/lib/nvidia-/libnvcuvid.so.
/usr/lib/nvidia-/libnvcuvid.so.367.57
/usr/lib32/nvidia-/libnvcuvid.so
/usr/lib32/nvidia-/libnvcuvid.so.
/usr/lib32/nvidia-/libnvcuvid.so.367.57
yuanlibin@yuanlibin:~/opencv-3.1./build$

本文软链接命令如下:

. sudo ln -s /usr/lib/nvidia-/libnvcuvid.so /usr/lib/libnvcuvid.so

如果显示已经存在,把相应的/usr/lib/libnvcuvid.so删除,重新编译。

编译出现错误(3)如下:

……
[ %] Building CXX object modules/cudalegacy/CMakeFiles/opencv_cudalegacy.dir/src/graphcuts.cpp.o
/home/yuanlibin/opencv-3.1./modules/cudalegacy/src/graphcuts.cpp::: error: ‘NppiGraphcutState’ has not been declared
typedef NppStatus (*init_func_t)(NppiSize oSize, NppiGraphcutState** ppState, Npp8u* pDeviceMem);
^
/home/yuanlibin/opencv-3.1./modules/cudalegacy/src/graphcuts.cpp::: error: expected type-specifier before ‘NppiGraphcutState’
operator NppiGraphcutState*()
^
/home/yuanlibin/opencv-3.1./modules/cudalegacy/src/graphcuts.cpp::: error: ‘NppiGraphcutState’ does not name a type
NppiGraphcutState* pState;
^
In file included from /home/yuanlibin/opencv-3.1./build/modules/cudalegacy/precomp.hpp:::
/home/yuanlibin/opencv-3.1./modules/cudalegacy/src/graphcuts.cpp: In constructor ‘{anonymous}::NppiGraphcutStateHandler::NppiGraphcutStateHandler(NppiSize, Npp8u*, {anonymous}::init_func_t)’:
/home/yuanlibin/opencv-3.1./modules/cudalegacy/src/graphcuts.cpp::: error: ‘pState’ was not declared in this scope
nppSafeCall( func(sznpp, &pState, pDeviceMem) );
^
/home/yuanlibin/opencv-3.1./modules/core/include/opencv2/core/private.cuda.hpp::: note: in definition of macro ‘nppSafeCall’
#define nppSafeCall(expr) cv::cuda::checkNppError(expr, __FILE__, __LINE__, CV_Func)
^
/home/yuanlibin/opencv-3.1./modules/cudalegacy/src/graphcuts.cpp: In destructor ‘{anonymous}::NppiGraphcutStateHandler::~NppiGraphcutStateHandler()’:
/home/yuanlibin/opencv-3.1./modules/cudalegacy/src/graphcuts.cpp::: error: ‘pState’ was not declared in this scope
nppSafeCall( nppiGraphcutFree(pState) );
^
……

解决方法:http://blog.csdn.net/xuzhongxiong/article/details/52717285

这是因为opecv3.0与cuda8.0不兼容导致的。修改 /home/yuanlibin/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp文件内容,如下:

//#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)//ziji zhushi
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION>=8000)//ziji tianjia

重新编译出现错误(4)如下:

[ %] Building CXX object samples/gpu/CMakeFiles/example_gpu_opticalflow_nvidia_api.dir/opticalflow_nvidia_api.cpp.o
Linking CXX executable ../../bin/gpu-example-opengl
CMakeFiles/example_gpu_opengl.dir/opengl.cpp.o: In function `draw(void*)':
opengl.cpp:(.text._Z4drawPv+0x21): undefined reference to `glRotated'
CMakeFiles/example_gpu_opengl.dir/opengl.cpp.o: In function `main':
opengl.cpp:(.text.startup.main+0x4ae): undefined reference to `glMatrixMode'
opengl.cpp:(.text.startup.main+0x4b3): undefined reference to `glLoadIdentity'
opengl.cpp:(.text.startup.main+0x4d8): undefined reference to `gluPerspective'
opengl.cpp:(.text.startup.main+0x4e2): undefined reference to `glMatrixMode'
opengl.cpp:(.text.startup.main+0x4e7): undefined reference to `glLoadIdentity'
opengl.cpp:(.text.startup.main+0x519): undefined reference to `gluLookAt'
opengl.cpp:(.text.startup.main+0x523): undefined reference to `glEnable'
opengl.cpp:(.text.startup.main+0x54b): undefined reference to `glTexParameteri'
opengl.cpp:(.text.startup.main+0x55f): undefined reference to `glTexEnvi'
opengl.cpp:(.text.startup.main+0x569): undefined reference to `glDisable'
collect2: error: ld returned exit status
Linking CXX executable ../../bin/gpu-example-optical_flow
make[]: *** [bin/gpu-example-opengl] Error
make[]: *** [samples/gpu/CMakeFiles/example_gpu_opengl.dir/all] Error
make[]: *** Waiting for unfinished jobs....
[ %] Built target example_gpu_optical_flow

解决方法:https://github.com/opencv/opencv/issues/5859

For fixing the problem, one more permanent solution is to add in /home/yuanlibin/opencv-3.1.0/samples/gpu/CMakeLists.txt the following lines:

find_package(OpenGL REQUIRED)#ziji tianjia
find_package(GLUT REQUIRED)#ziji tianjia #ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})#yuanlaide
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS} ${OPENGL_LIBRARIES} ${GLUT_LIBRARY})#ziji tianjia

最终编译成功,终端显示如下:

[ %] Build Java tests
Linking CXX executable ../../bin/cpp-tutorial-video-write
Buildfile: /home/yuanlibin/opencv-3.1./build/modules/java/pure_test/.build/build.xml
[ %] Built target tutorial_video-write
Linking CXX executable ../../bin/cpp-tutorial-video-input-psnr-ssim
Linking CXX executable ../../bin/cpp-tutorial-planar_tracking build: compile:
[javac] Compiling source files to /home/yuanlibin/opencv-3.1./build/modules/java/pure_test/.build/build/classes
[ %] Built target tutorial_planar_tracking
[ %] Built target tutorial_video-input-psnr-ssim jar:
[jar] Building jar: /home/yuanlibin/opencv-3.1./build/modules/java/pure_test/.build/build/jar/opencv-test.jar BUILD SUCCESSFUL
Total time: seconds
[%] Built target opencv_test_java
yuanlibin@yuanlibin:~/opencv-3.1./build$

再执行一次,终端显示如下:

yuanlibin@yuanlibin:~/opencv-3.1./build$ make -j4
[ %] [ %] [ %] Built target opencv_ts_pch_dephelp
Built target opencv_cudev
Built target opencv_core_pch_dephelp
[ %] Built target libwebp
[ %] [ %] Built target opencv_imgproc_pch_dephelp
Built target opencv_imgcodecs_pch_dephelp
[ %] Built target opencv_highgui_pch_dephelp
[ %] [ %] Built target opencv_perf_core_pch_dephelp
Built target opencv_videoio_pch_dephelp
[ %] Built target opencv_cudaarithm_pch_dephelp
[ %] Built target opencv_perf_cudaarithm_pch_dephelp
[ %] [ %] Built target opencv_test_core_pch_dephelp
Built target opencv_test_cudaarithm_pch_dephelp
[ %] Built target opencv_flann_pch_dephelp
[ %] Built target opencv_test_flann_pch_dephelp
[ %] Built target opencv_perf_imgproc_pch_dephelp
[ %] Built target opencv_test_imgproc_pch_dephelp
[ %] Built target opencv_test_ml_pch_dephelp
[ %] [ %] Built target opencv_ml_pch_dephelp
Built target opencv_video_pch_dephelp
[ %] [ %] Built target opencv_test_video_pch_dephelp
Built target opencv_perf_video_pch_dephelp
[ %] [ %] Built target opencv_test_viz_pch_dephelp
Built target opencv_viz_pch_dephelp
[ %] Built target opencv_perf_cudabgsegm_pch_dephelp
[ %] Built target opencv_cudabgsegm_pch_dephelp
[ %] [ %] Built target opencv_test_cudabgsegm_pch_dephelp
Built target opencv_cudafilters_pch_dephelp
[ %] Built target opencv_perf_cudafilters_pch_dephelp
[ %] Built target opencv_test_cudafilters_pch_dephelp
[ %] [ %] Built target opencv_perf_cudaimgproc_pch_dephelp
Built target opencv_cudaimgproc_pch_dephelp
[ %] Built target opencv_test_cudaimgproc_pch_dephelp
[ %] Built target opencv_cudawarping_pch_dephelp
[ %] Built target opencv_perf_cudawarping_pch_dephelp
[ %] Built target opencv_test_cudawarping_pch_dephelp
[ %] Built target opencv_perf_imgcodecs_pch_dephelp
[ %] Built target opencv_perf_photo_pch_dephelp
[ %] Built target opencv_photo_pch_dephelp
[ %] Built target opencv_test_imgcodecs_pch_dephelp
[ %] Built target opencv_test_photo_pch_dephelp
[ %] [ %] [ %] Built target opencv_test_shape_pch_dephelp
Built target opencv_shape_pch_dephelp
Built target opencv_perf_videoio_pch_dephelp
[ %] [ %] [ %] [ %] Built target opencv_test_cudacodec_pch_dephelp
Built target opencv_perf_cudacodec_pch_dephelp
Built target opencv_cudacodec_pch_dephelp
Built target opencv_test_videoio_pch_dephelp
[ %] [ %] [ %] Built target opencv_perf_objdetect_pch_dephelp
Built target opencv_test_highgui_pch_dephelp
Built target opencv_test_objdetect_pch_dephelp
[ %] Built target opencv_objdetect_pch_dephelp
[ %] [ %] Built target opencv_perf_features2d_pch_dephelp
Built target opencv_test_features2d_pch_dephelp
[ %] Built target opencv_features2d_pch_dephelp
[ %] Built target opencv_calib3d_pch_dephelp
[ %] [ %] Built target opencv_perf_calib3d_pch_dephelp
Built target opencv_test_calib3d_pch_dephelp
[ %] [ %] Built target opencv_perf_cudafeatures2d_pch_dephelp
Built target opencv_cudafeatures2d_pch_dephelp
[ %] Built target opencv_test_cudafeatures2d_pch_dephelp
[ %] Built target opencv_cudalegacy_pch_dephelp
[ %] Built target opencv_perf_cudalegacy_pch_dephelp
[ %] [ %] Built target opencv_test_cudalegacy_pch_dephelp
Built target opencv_cudaobjdetect_pch_dephelp
[ %] Built target opencv_perf_cudaobjdetect_pch_dephelp
[ %] Built target opencv_test_cudaobjdetect_pch_dephelp
[ %] [ %] Built target opencv_perf_cudaoptflow_pch_dephelp
Built target opencv_test_cudaoptflow_pch_dephelp
[ %] Built target opencv_cudaoptflow_pch_dephelp
[ %] Built target opencv_cudastereo_pch_dephelp
[ %] Built target opencv_test_cudastereo_pch_dephelp
[ %] Built target opencv_perf_cudastereo_pch_dephelp
[ %] Built target opencv_perf_stitching_pch_dephelp
[ %] [ %] [ %] Built target opencv_stitching_pch_dephelp
Built target opencv_test_stitching_pch_dephelp
Built target opencv_perf_superres_pch_dephelp
[ %] [ %] [ %] Built target opencv_superres_pch_dephelp
Built target opencv_test_superres_pch_dephelp
Built target pch_Generate_opencv_ts
[ %] Built target opencv_videostab_pch_dephelp
[ %] [ %] [ %] Built target pch_Generate_opencv_imgcodecs
Built target pch_Generate_opencv_core
Built target pch_Generate_opencv_imgproc
[ %] Built target pch_Generate_opencv_videoio
[ %] [ %] Built target pch_Generate_opencv_highgui
Built target pch_Generate_opencv_test_core
[ %] [ %] Built target pch_Generate_opencv_perf_core
Built target pch_Generate_opencv_cudaarithm
[ %] Built target pch_Generate_opencv_perf_cudaarithm
[ %] Built target pch_Generate_opencv_test_cudaarithm
[ %] [ %] Built target pch_Generate_opencv_flann
Built target pch_Generate_opencv_test_flann
[ %] [ %] Built target pch_Generate_opencv_perf_imgproc
Built target pch_Generate_opencv_test_imgproc
[ %] [ %] Built target pch_Generate_opencv_ml
Built target pch_Generate_opencv_test_ml
[ %] [ %] Built target pch_Generate_opencv_video
Built target pch_Generate_opencv_perf_video
[ %] Built target pch_Generate_opencv_viz
[ %] [ %] Built target pch_Generate_opencv_test_video
Built target pch_Generate_opencv_test_viz
[ %] Built target pch_Generate_opencv_cudabgsegm
[ %] Built target pch_Generate_opencv_perf_cudabgsegm
[ %] [ %] Built target pch_Generate_opencv_test_cudabgsegm
Built target pch_Generate_opencv_cudafilters
[ %] Built target pch_Generate_opencv_perf_cudafilters
[ %] Built target pch_Generate_opencv_test_cudafilters
[ %] Built target pch_Generate_opencv_cudaimgproc
[ %] Built target pch_Generate_opencv_perf_cudaimgproc
[ %] Built target pch_Generate_opencv_test_cudaimgproc
[ %] Built target pch_Generate_opencv_cudawarping
[ %] [ %] [ %] Built target pch_Generate_opencv_perf_cudawarping
Built target pch_Generate_opencv_perf_imgcodecs
Built target pch_Generate_opencv_test_cudawarping
[ %] Built target pch_Generate_opencv_test_imgcodecs
[ %] [ %] [ %] Built target pch_Generate_opencv_perf_photo
Built target pch_Generate_opencv_photo
Built target pch_Generate_opencv_test_photo
[ %] [ %] [ %] Built target pch_Generate_opencv_shape
Built target pch_Generate_opencv_test_videoio
Built target pch_Generate_opencv_test_shape
[ %] Built target pch_Generate_opencv_perf_videoio
[ %] [ %] Built target pch_Generate_opencv_cudacodec
Built target pch_Generate_opencv_perf_cudacodec
[ %] Built target pch_Generate_opencv_test_cudacodec
[ %] Built target pch_Generate_opencv_test_highgui
[ %] [ %] [ %] Built target pch_Generate_opencv_objdetect
Built target pch_Generate_opencv_perf_objdetect
Built target pch_Generate_opencv_test_objdetect
[ %] Built target pch_Generate_opencv_features2d
[ %] [ %] [ %] Built target pch_Generate_opencv_test_features2d
Built target pch_Generate_opencv_perf_features2d
Built target pch_Generate_opencv_calib3d
[ %] Built target pch_Generate_opencv_perf_calib3d
[ %] [ %] Built target pch_Generate_opencv_test_calib3d
Built target pch_Generate_opencv_cudafeatures2d
[ %] [ %] Built target pch_Generate_opencv_test_cudafeatures2d
Built target pch_Generate_opencv_perf_cudafeatures2d
[ %] [ %] Built target pch_Generate_opencv_perf_cudalegacy
Built target pch_Generate_opencv_cudalegacy
[ %] Built target pch_Generate_opencv_cudaobjdetect
[ %] [ %] Built target pch_Generate_opencv_test_cudaobjdetect
Built target pch_Generate_opencv_perf_cudaobjdetect
[ %] Built target pch_Generate_opencv_test_cudalegacy
[ %] Built target pch_Generate_opencv_cudaoptflow
[ %] [ %] Built target pch_Generate_opencv_test_cudaoptflow
Built target pch_Generate_opencv_perf_cudaoptflow
[ %] [ %] Built target pch_Generate_opencv_cudastereo
Built target pch_Generate_opencv_perf_cudastereo
[ %] Built target pch_Generate_opencv_perf_stitching
[ %] Built target pch_Generate_opencv_test_cudastereo
[ %] Built target pch_Generate_opencv_stitching
[ %] Built target pch_Generate_opencv_test_stitching
[ %] [ %] Built target pch_Generate_opencv_perf_superres
Built target pch_Generate_opencv_superres
[ %] Built target pch_Generate_opencv_test_superres
[ %] Built target pch_Generate_opencv_videostab
[ %] Built target opencv_core
[ %] Built target opencv_flann
[ %] Built target opencv_ml
[ %] Built target opencv_viz
[ %] Built target opencv_imgproc
[ %] Built target opencv_cudaarithm
[ %] [ %] Built target opencv_cudawarping
Built target opencv_video
[ %] Built target opencv_imgcodecs
[ %] Built target opencv_shape
[ %] Built target opencv_cudabgsegm
[ %] Built target opencv_videoio
[ %] Built target opencv_cudafilters
[ %] Built target opencv_highgui
[ %] Built target opencv_cudacodec
[ %] Built target opencv_objdetect
[ %] Built target opencv_annotation
[ %] Built target opencv_ts
[ %] Built target opencv_perf_core
[ %] Built target opencv_features2d
[ %] Built target opencv_perf_cudaarithm
[ %] Built target opencv_cudaimgproc
[ %] Built target opencv_test_cudev
[ %] Built target opencv_test_cudaarithm
[ %] Built target opencv_test_flann
[ %] Built target opencv_test_core
[ %] Built target opencv_test_ml
[ %] [ %] Built target opencv_perf_video
Built target opencv_perf_imgproc
[ %] Built target opencv_test_video
[ %] [ %] Built target opencv_perf_cudabgsegm
Built target opencv_test_viz
[ %] Built target opencv_test_cudabgsegm
[ %] [ %] Built target opencv_perf_cudafilters
Built target opencv_test_cudafilters
[ %] [ %] Built target opencv_test_cudaimgproc
Built target opencv_perf_cudaimgproc
[ %] Built target opencv_perf_cudawarping
[ %] Built target opencv_perf_imgcodecs
[ %] Built target opencv_test_cudawarping
[ %] [ %] [ %] Built target opencv_test_imgcodecs
Built target opencv_test_imgproc
Built target opencv_test_shape
[ %] Built target opencv_perf_videoio
[ %] Built target opencv_perf_cudacodec
[ %] [ %] Built target opencv_test_cudacodec
Built target opencv_test_videoio
[ %] Built target opencv_photo
[ %] Built target opencv_test_highgui
[ %] Built target opencv_perf_objdetect
[ %] Built target opencv_perf_features2d
[ %] Built target opencv_test_objdetect
[ %] Built target opencv_test_features2d
[ %] Built target opencv_perf_photo
[ %] Built target opencv_test_photo
[ %] Built target opencv_calib3d
[ %] Built target opencv_cudafeatures2d
[ %] Built target opencv_perf_calib3d
[ %] Built target opencv_test_calib3d
[ %] Built target opencv_cudastereo
[ %] Built target opencv_createsamples
[ %] Built target opencv_cudalegacy
[ %] Built target opencv_traincascade
[ %] Built target example_tapi_bgfg_segm
[ %] Built target example_tapi_camshift
[ %] [ %] Built target example_tapi_hog
Built target example_tapi_clahe
[ %] Built target example_tapi_pyrlk_optical_flow
[ %] Built target example_tapi_squares
[ %] Built target example_tapi_tvl1_optical_flow
[ %] Built target example_tapi_ufacedetect
[ %] Built target opencv_perf_cudafeatures2d
[ %] Built target opencv_test_cudafeatures2d
[ %] Built target opencv_java
[ %] Built target opencv_perf_cudalegacy
[ %] Built target opencv_perf_cudastereo
[ %] Built target opencv_cudaobjdetect
[ %] [ %] Built target opencv_test_cudastereo
Built target opencv_test_cudalegacy
[ %] Built target opencv_cudaoptflow
[ %] Built target opencv_test_java_properties
[ %] Built target opencv_test_cudaobjdetect
[ %] Built target opencv_perf_cudaobjdetect
[ %] Built target opencv_perf_cudaoptflow
[ %] Built target opencv_test_cudaoptflow
[ %] Built target opencv_test_java
[ %] Built target opencv_stitching
[ %] Built target opencv_superres
[ %] Built target opencv_test_stitching
[ %] Built target opencv_perf_stitching
[ %] Built target opencv_perf_superres
[ %] Built target opencv_test_superres
[ %] [ %] [ %] Built target example_gpu_bgfg_segm
Built target opencv_videostab
Built target example_gpu_alpha_comp
[ %] Built target example_gpu_cascadeclassifier
[ %] Built target example_gpu_driver_api_multi
[ %] [ %] Built target example_gpu_cascadeclassifier_nvidia_api
Built target example_gpu_driver_api_stereo_multi
[ %] [ %] Built target example_gpu_farneback_optical_flow
Built target example_gpu_generalized_hough
[ %] [ %] Built target example_gpu_houghlines
Built target example_gpu_hog
[ %] [ %] Built target example_gpu_multi
Built target example_gpu_morphology
[ %] [ %] Built target example_gpu_optical_flow
Built target example_gpu_opengl
[ %] Built target example_gpu_performance
[ %] Built target example_gpu_opticalflow_nvidia_api
[ %] Built target example_gpu_stereo_match
[ %] Built target example_gpu_pyrlk_optical_flow
[ %] Built target example_gpu_stereo_multi
[ %] Built target example_gpu_super_resolution
[ %] Built target example_gpu_video_reader
[ %] Built target example_gpu_surf_keypoint_matcher
[ %] Built target example_gpu_video_writer
[ %] Built target opencv_python2
[ %] Built target opencv_python3
[ %] Built target cpp-tutorial-pnp_detection
[ %] Built target example_3calibration
[ %] [ %] Built target example_autofocus
Built target cpp-tutorial-pnp_registration
[ %] Built target example_bgfg_segm
[ %] [ %] Built target example_calibration
Built target example_cloning_demo
[ %] Built target example_camshiftdemo
[ %] Built target example_cloning_gui
[ %] [ %] Built target example_contours2
Built target example_connected_components
[ %] Built target example_convexhull
[ %] Built target example_cout_mat
[ %] [ %] Built target example_create_mask
Built target example_dbt_face_detection
[ %] Built target example_delaunay2
[ %] Built target example_demhist
[ %] Built target example_detect_mser
[ %] Built target example_detect_blob
[ %] Built target example_dft
[ %] Built target example_distrans
[ %] [ %] Built target example_drawing
Built target example_edge
[ %] Built target example_em
[ %] [ %] Built target example_example
Built target example_facedetect
[ %] Built target example_facial_features
[ %] Built target example_fback
[ %] [ %] Built target example_filestorage
Built target example_ffilldemo
[ %] Built target example_fitellipse
[ %] [ %] [ %] Built target example_houghcircles
Built target example_grabcut
Built target example_houghlines
[ %] Built target example_image
[ %] Built target example_image_sequence
[ %] [ %] Built target example_image_alignment
Built target example_imagelist_creator
[ %] [ %] Built target example_intelperc_capture
Built target example_inpaint
[ %] Built target example_kalman
[ %] [ %] Built target example_laplace
[ %] Built target example_kmeans
Built target example_letter_recog
[ %] Built target example_lkdemo
[ %] Built target example_logistic_regression
[ %] Built target example_lsd_lines
[ %] Built target example_mask_tmpl
[ %] Built target example_matchmethod_orb_akaze_brisk
[ %] [ %] Built target example_minarea
Built target example_morphology2
[ %] Built target example_npr_demo
[ %] Built target example_opencv_version
[ %] Built target example_phase_corr
[ %] [ %] Built target example_pca
Built target example_openni_capture
[ %] Built target example_points_classifier
[ %] Built target example_polar_transforms
[ %] [ %] Built target example_select3dobj
Built target example_segment_objects
[ %] Built target example_shape_example
[ %] [ %] [ %] Built target example_starter_imagelist
Built target example_smiledetect
Built target example_squares
[ %] Built target example_starter_video
[ %] Built target example_stereo_calib
[ %] Built target example_stitching
[ %] Built target example_stereo_match
[ %] [ %] Built target example_train_HOG
Built target example_stitching_detailed
[ %] Built target example_tree_engine
[ %] Built target example_tvl1_optical_flow
[ %] Built target example_watershed
[ %] Built target example_videostab
[ %] Built target tutorial_AKAZE_match
[ %] Built target tutorial_AddingImages
[ %] [ %] Built target tutorial_AddingImagesTrackbar
Built target tutorial_BasicLinearTransforms
[ %] Built target tutorial_BasicLinearTransformsTrackbar
[ %] Built target tutorial_CannyDetector_Demo
[ %] [ %] [ %] Built target tutorial_Drawing_2
Built target tutorial_Drawing_1
Built target tutorial_EqualizeHist_Demo
[ %] Built target tutorial_Geometric_Transforms_Demo
[ %] [ %] [ %] Built target tutorial_LATCH_match
Built target tutorial_HoughCircle_Demo
Built target tutorial_HoughLines_Demo
[ %] Built target tutorial_Laplace_Demo
[ %] [ %] Built target tutorial_MatchTemplate_Demo
[ %] Built target tutorial_Morphology_2
Built target tutorial_Morphology_1
[ %] Built target tutorial_Morphology_3
[ %] Built target tutorial_Pyramids
[ %] Built target tutorial_SBM_Sample
[ %] Built target tutorial_Remap_Demo
[ %] Built target tutorial_Smoothing
[ %] Built target tutorial_Sobel_Demo
[ %] Built target tutorial_Threshold
[ %] Built target tutorial_bg_sub
[ %] [ %] Built target tutorial_calcBackProject_Demo1
Built target tutorial_calcBackProject_Demo2
[ %] Built target tutorial_calcHist_Demo
[ %] Built target tutorial_camera_calibration
[ %] [ %] Built target tutorial_cloning_gui
Built target tutorial_cloning_demo
[ %] Built target tutorial_compareHist_Demo
[ %] Built target tutorial_copyMakeBorder_demo
[ %] Built target tutorial_cornerDetector_Demo
[ %] Built target tutorial_cornerHarris_Demo
[ %] [ %] [ %] Built target tutorial_cornerSubPix_Demo
Built target tutorial_decolor
Built target tutorial_discrete_fourier_transform
[ %] Built target tutorial_display_image
[ %] [ %] [ %] Built target tutorial_findContours_demo
Built target tutorial_file_input_output
Built target tutorial_filter2D_demo
[ %] [ %] [ %] [ %] Built target tutorial_gdal-image
Built target tutorial_generalContours_demo1
Built target tutorial_goodFeaturesToTrack_Demo
Built target tutorial_generalContours_demo2
[ %] [ %] [ %] Built target tutorial_gpu-basics-similarity
Built target tutorial_hdr_imaging
Built target tutorial_how_to_scan_images
[ %] Built target tutorial_hull_demo
[ %] [ %] [ %] Built target tutorial_imageSegmentation
Built target tutorial_interoperability_with_OpenCV_1
Built target tutorial_introduction_to_pca
[ %] Built target tutorial_introduction_to_svm
[ %] [ %] Built target tutorial_mat_the_basic_image_container
Built target tutorial_mat_mask_operations
[ %] [ %] Built target tutorial_introduction_windows_vs
Built target tutorial_moments_demo
[ %] [ %] Built target tutorial_npr_demo
Built target tutorial_non_linear_svms
[ %] [ %] Built target tutorial_objectDetection2
Built target tutorial_objectDetection
[ %] [ %] Built target tutorial_pointPolygonTest_demo
Built target tutorial_planar_tracking
[%] Built target tutorial_video-write
[%] Built target tutorial_video-input-psnr-ssim
yuanlibin@yuanlibin:~/opencv-3.1./build$

最后执行安装命令:

. sudo make install

至此OpenCV3.1.0编译安装全部完成,指定安装到路径/usr/local/opencv_3.1.0。

这样GPU版本的opencv就编译安装完成了,可以调用opencv中GPU相关的函数。

 

上一篇:Bash一键替换/清除文本文档中的跨行注释


下一篇:四则运算安卓客户端UI截图(部分)