Ubuntu系统opencv源码安装
#安装各依赖项:
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
#克隆源码(选择自己需要的版本)或者去官网下载
git clone https://github.com/opencv/opencv.git
cd opencv/
git checkout 4.1.0
#Building
创建一个build文件夹,在build目录下执行cmake
cmake只带了路径和cmake方式
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local ..
sudo make -j$(nproc)
sudo make install
sudo ldconfig
#如果需要其他选项:
//比如opencv用于指定python环境
-D INSTALL_PYTHON_EXAMPLES=ON \
-D PYTHON_EXECUTABLE=$(which python3) \
-D BUILD_opencv_python2=OFF \
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
//启用gstreamer
-D WITH_GSTREAMER=ON \