1. Download the opencv3.2.0 installation package and go to the official website: http://opencv.org/releases.html , select the source of version 3.2.0, and download opencv-3.2.0.zip.
2. Install some libraries required by opencv, and try to install them as much as possible:
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 sudo apt-get install --assume-yes libopencv-dev libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip sudo apt-get install ffmpeg libopencv-dev libgtk-3-dev python-numpy python3-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libv4l-dev libtbb-dev qtbase5-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev sudo apt-get install libgtk-3-dev sudo apt-get -y install libgstreamer-plugins-base1.0-dev sudo apt-get -y install libgstreamer1.0-dev sudo apt-get -y install libavresample-dev sudo apt-get -y install libgphoto2-dev sudo apt-get install libopenblas-dev sudo apt-get install doxygen
3. Place the installation package in the root directory, unzip it, and then execute the command:
cd opencv-3.2.0 mkdir build cd build cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler .. sudo make -j12
4. Troubleshooting:
- Problem 1: ICV: downloading ippicv? Linux? 20151201.tgz download stuck, timeout
Solution: Download manually: ippicv_linux_20151201.tgz
Replace the file with the same name in opencv-3.2.0/3rdparty/ippicv/downloads/linux - * directory after loading, and then try cmake again.
- Problem 2: the following error occurred because cuda9 no longer supports the 2.0 architecture
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_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
Solution: after the following steps are completed, re cmake
1. Find the FindCUDA.cmake file under / home/xxx/opencv-3.2.0/cmake:
Will: find_cuda_helper_libs(nppi) //Changed to: 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) ---------------------------------- //Will: set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}") //Changed to: 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}") --------------------------------- //Will: unset(CUDA_nppi_LIBRARY CACHE) //Changed to: 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)
2. Find the OpenCVDetectCUDA.cmake file under / home/xxx/opencv-3.2.0/cmake:
Will: ... 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") elseif(CUDA_GENERATION STREQUAL "Maxwell") set(__cuda_arch_bin "5.0 5.2") ... //Changed to: ... 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") ...
3. Find the common.hpp file under / home/xxx/opencv-3.2.0/opencv/modules/cudev/include/opencv2/cudev:
Add to:
#include <cuda_fp16.h>
- Question 3: fatal error: LAPACK? H? Path-notfound / LAPACK. H: no such file or directory? Include "LAPACK? H? Path-notfound / LAPACK. H"
Solve:
sudo apt-get install liblapacke-dev checkinstall
Modify opencv-3.2.0/build/opencv.h.
Will: #include"LAPACKE_H_PATH-NOTFOUND/lapacke.h" //Changed to: #include"lapacke.h"
- Question 4: nvcc fatal: Unsupported GPU architecture 'compute 20'
Solve:
As long as you follow the above:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D
There should be no mistakes.
- Question 5: videodev.h -- linux/videodev.h not found
Solve:
sudo ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h
Successful results:
5. Install after compilation:
sudo make install
Successful results:
6. After the installation, verify whether the installation is successful by checking the opencv version:
pkg-config --modversion opencv
Successful results:
3.2.0