1、进入下载opencv3.4.1.zip
https://github.com/opencv/opencv/archive/3.4.1.zip
2、解压安装包
unzip opencv3.4.1.zip
3、安装依赖包
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff5.dev libswscale-dev libjasper-dev
当出现如下问题时:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libjpeg-dev' for regex 'libjpeg.dev'
Note, selecting 'libtiff5-dev' for regex 'libtiff5.dev'
E: Unable to locate package libjasper-dev
解决方法:
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev
4、编译
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j8
sudo make install
编译过程可能遇到的问题,解决方法:
sudo apt-get install build-essential libgtk-3-dev
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
apt-get install libdc1394-22-dev
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libavutil-dev
sudo apt-get -y install libavresample-dev
sudo apt-get -y install libgphoto2-dev
sudo apt-get install -y openjdk-8-jdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
网络不好导致下载失败ippicv_2020_lnx_intel64_20191018_general.tgz问题解决
cd /home/***/install/opencv-3.4.11/3rdparty/ippicv
gedit ippicv.cmake
"file:///home/***/install/opencv-3.4.11/3rdparty/ippicv/"
###https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/
5、配置opencv库和bash
sudo gedit /etc/ld.so.conf.d/opencv.conf
文件末尾添加: /usr/local/lib
sudo ldconfig
sudo gedit /etc/bash.bashrc
文件末尾添加
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
激活
source /etc/bash.bashrc
更新
sudo updatedb
6、测试小栗子
见附件:
https://download.csdn.net/download/u011735367/86946484
参考资料:
https://blog.csdn.net/qq_45999753/article/details/109316118
https://blog.csdn.net/qq_42985179/article/details/109312065