下载:
1、opencv 4.9
2、opencv_contrilb 4.x
基础依赖库
sudo apt install -y cmake make
sudo apt install -y build-essential
sudo apt install -y libgtk2.0-dev
sudo apt install -y libavcodec-dev
sudo apt install -y libavformat-dev
sudo apt install -y libjpeg-dev
sudo apt install -y libtiff-dev
sudo apt install -y libswscale-dev
sudo apt install -y libpng-dev
sudo add-apt-repository 'deb http://security.ubuntu.com/ubuntu xenial-security main'
sudo apt update
sudo apt install libjasper1 libjasper-dev
sudo apt install -y freeglut3-dev
sudo apt install -y libgl1-mesa-dev
sudo apt install -y pkg-config
sudo apt update
sudo apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev libgstreamer-plugins-good1.0-dev
sudo apt install -y gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly
sudo apt install -y gstreamer1.0-tools gstreamer1.0-libav
sudo apt install -y gstreamer1.0-doc gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
# 安装gtk2支持
sudo apt-get install libgtk2.0-dev
# 安装gtk3支持
sudo apt-get install libgtk-3-dev
编译
mkdir build
cd build
sudo cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D OPENCV_GENERATE_PKGCONFIG=ON \ -D BUILD_EXAMPLES=OFF \ -D INSTALL_PYTHON_EXAMPLES=OFF \ -D INSTALL_C_EXAMPLES=OFF \ -D WITH_GSTREAMER=ON \ -D OPENCV_EXTRA_MODULES_PATH=/home/a/opencv-4.9.0/opencv_contrib-4.x/modules/ ...
sudo make
sudo make install
检查
pkg-config opencv4 --modversion