# 编译OpenCV + OpenCV contrib 参考: https://docs.opencv.org/3.1.0/d7/d9f/tutorial_linux_install.html 为了满足要求:
- 版本 3.1.0及以上 - OpenCV和OpenCV contrib版本要求一致
建议使用git clone 并切换到对应的版本tag上。
cd ~/<my_working_directory>
git clone https://github.com/Itseez/opencv.git -b 3.1.0 git clone https://github.com/Itseez/opencv_contrib.git -b 3.1.01 cd ~/opencv
2 mkdir build 3 cd build
OpenCV cmake 命令 (自己修改安装路径和opencv_contrib下载路径):
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local/opencv-3.1.0/ \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=/media/andy/6571da9e-ba8c-446a-b2a7-6f9871a996e5/andy/opencv/opencv_contrib/modules \
-D PYTHON_EXCUTABLE=/usr/local/opencv-3.1.0/bin/python \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D WITH_GTK=ON \
-D WITH_OPENGL=ON \
-D BUILD_EXAMPLES=ON \
-D WITH_IPP=OFF \
..
解决:ICV hash 问题
-- ICV: Downloading ippicv_linux_20151201.tgz... CMake Error at 3rdparty/ippicv/downloader.cmake:73 (file): file DOWNLOAD HASH mismatch参考:
https://github.com/opencv/opencv/issues/8372
-D WITH_IPP=OFF
编译:
make -j7 # runs 7 jobs in parallel
安装:
sudo make install
issue: error: ‘NppiGraphcutState’ ... ``` open "modules/cudalegacy/src/graphcuts.cpp" change #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) to #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000) Worked for me. Hope it will save someone's day... ```ref: https://github.com/opencv/opencv/issues/6677
issue: les/hdf/include/opencv2/hdf/hdf5.hpp:40:18: fatal error: hdf5.h: No such file or directory
sudo apt-get install libhdf5-devref: https://github.com/opencv/opencv/issues/6677
https://github.com/opencv/opencv/issues/6050
