Ubuntu18.04+opencv4.4+ffmpeg
安裝前把anaconda卸載了。
gcc-7
安裝
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-7
sudo apt-get install g++-7
添加版本及優先級
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 100
查看版本
gcc -v
g++ -v
切換版本
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
ffmpeg
安裝
sudo apt-get install ffmpeg
查看版本
ffmpeg -version
依賴
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg-dev libswscale-dev libtiff5-dev
sudo apt-get install libgtk2.0-dev
sudo apt-get install pkg-config
opencv-4.4以及opencv_contrib-4.4.0
資源
其他依賴
鏈接:https://pan.baidu.com/s/1PCkEOwJ0xWyPmm0mw4yJ2w
提取碼:g1zp
復制這段內容后打開百度網盤手機App,操作更方便哦
ipccv
boostdesc_bgm.i,vgg_generated_48.i等11個文件,ippicv等已下載好,請自行提取
鏈接:https://pan.baidu.com/s/1ZEMGaJslbxLDwAGhJaodFQ 提取碼:yyd7
復制這段內容后打開百度網盤手機App,操作更方便哦
編譯
-
解壓opencv-4.4、opencv_contrib-4.4.0、其他依賴
-
將其他依賴復制到opencv-contrib-4.4/modules/xfeatures2d/src下
-
將ippicv復制到opencv-4.4/3rdparty/ippicv/下
- 修改opencv-4.4/3rdparty/ippicv/ippicv.cmake
URL
"${OPENCV_IPPICV_URL}"
"$ENV{OPENCV_IPPICV_URL}"
file:./ippicv_2020_lnx_intel64_20191018_general.tgz
#"https://raw.githubusercontent.com/opencv-3rdparty/${IPPICV_COMMIT}/ippicv/"
- 將opencv_contrib-4.4.0移動到opencv-4.4.0下
- 在opencv-4.4.0文件夾下創建目錄build
- 將opencv-4.4.0/modules/features2d復制到build目錄中
生成
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.4.0/modules .. -DWITH_CUDA=1 -DWITH_FFMPEG=ON -DWITH_GSTREAMER=ON -DENABLE_FAST_MATH=1 -DCUDA_FAST_MATH=1 -DWITH_CUBLAS=1 -DWITH_GTK=ON -DOPENCV_GENERATE_PKGCONFIG=1 -DCUDA_GENERATION=Pascal ..
編譯OpenCV以及openc_contrib提示缺少boostdesc_bgm.i文件出錯的解決
將部分難下載的文件拷貝到build/.cache/xfeatures2d
下面對應的目錄下,或者多編譯幾遍(多下載幾遍文件)。
編譯
sudo make -j6
安裝
sudo make install
修改環境變量
# 在/etc/ld.so.conf下添加
/usr/local/lib
刷新
sudo ldconfig
# 在/etc/bash.bashrc下添加
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
# 刷新
source /etc/bash.bashrc
檢查是否安裝成功
pkg-config opencv4 --modversion
參考
ubuntu16.04安裝gcc g++7.5.0 添加版本優先級及各個版本的切換
ubuntu18.04 編譯opencv4.4.0 帶cuda加速,ffmpeg
[編譯OpenCV提示opencv_contrib缺少boostdesc_bgm.i等文件](https://www.cnblogs.com/arxive/p/11778731.html)
Ubuntu系統opencv4.4安裝常見問題 找不到 feature2d/test/test_detectors_regression.impl.hpp 文件