一、卸载OpenCV


二、下载 opencv opencv—contrib 的压缩包


点此下载:OpenCV下载地址

点此下载:OpenCV-contrib下载地址

建议目前下载 4.4 以上的,有 YOLO4 的接口

下载后解压至自己选择的地方,解压的地方建议放在 opencvx.x 文件夹的同级目录下即可

三、下载依赖包


已有的依赖包可以不用重复下载

# 安装python部分
sudo apt install python3-dev python3-pip -y
#sudo pip3 install cython setuptools numpy
sudo -H pip3 install -U pip numpy
sudo apt install python3-testresources

# 安装依赖包以及工具 
sudo apt install gcc-arm* build-essential cmake git unzip pkg-config yasm checkinstall -y
sudo apt install libprotobuf-dev protobuf-compiler libgflags-dev libgoogle-glog-dev -y
sudo apt install libjpeg-dev libpng-dev libtiff-dev -y
sudo apt install libavcodec-dev libavformat-dev libavutil-dev libxvidcore-dev libswscale-dev libx264-dev libavresample-dev libfaac-dev libmp3lame-dev libtheora-dev -y
sudo apt install liblapack-dev libxine2-dev gfortran libvorbis-dev -y
sudo apt install libpostproc-dev -y
sudo apt install libmpikmeans-dev libmpikmeans1 mpi-default-dev -y
sudo apt install libgtk-3-dev -y

对于libjasper-dev, 它只在 Ubuntu Xenial 之前提供这里添加清华源下载⚠️(下面的清华源暂时用不了)

sudo add-apt-repository "deb <http://security.ubuntu.com/ubuntu> xenial-security main"
sudo apt update
sudo apt-get install  libjasper-dev -y