首先安装FFMpeg,参考这个链接
安装编译工具
yum install gcc gcc-c++ kernel-devel make
然后在opencv官网下载source版本的opencv。
mkdir build & cd build
接下来是配置CMake,关键(也可以用cmake gui来做)
cmake -D CMAKE_BUILD_TYPE=Release -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D BUILD_EXAMPLES=ON -D CMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs -D WITH_CUDA=ON -DBUILD_TIFF=ON -DBUILD_opencv_java=OFF -DWITH_OPENGL=ON -DWITH_OPENCL=ON -DWITH_IPP=ON -DWITH_TBB=ON -DWITH_EIGEN=ON -DWITH_V4L=ON -DWITH_VTK=OFF -DBUILD_TESTS=OFF -DBUILD_opencv_dnn=ON -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES --expt-relaxed-constexpr" -DBUILD_LIBPROTOBUF_FROM_SOURCES=ON -DBUILD_PERF_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$(python -c "import sys; print(sys.prefix)") -DPYTHON3_EXECUTABLE=$(which python) -DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -DPYTHON_PACKAGES_PATH=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") -DPYTHON3_NUMPY_INCLUDE_DIRS=$(python -c "import numpy; import os; print(os.path.join(numpy.__path__[0], 'core', 'include'))") -DPYTHON_LIBRARY=/home/myname/anaconda3/envs/segment/lib/libpython3.6m.so ..
然后就是
make -j8
make install
完成