官方地址(镜像):
JetPack SDK
博主用的是目前的最新款(JetPack 4.4)
换源
sudo vim /etc/apt/sources.list
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
esc :wq 保存退出
sudo apt-get update
sudo apt-get upgrade
安装依赖
sudo apt-get install zram-config
sudo vim /usr/bin/init-zram-swapping
sudo apt update
sudo apt install -y build-essential cmake git libgtk2.0-dev pkg-config libswscale-dev libtbb2 libtbb-dev
sudo apt install -y python-dev python3-dev python-numpy pyhton3-numpy
sudo apt install -y curl
sudo apt install -y libjpeg-dev libpng-dev libtiff-dev libjasper-dev
sudo apt install -y libavcodec-dev libavformat-dev
sudo apt install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt install -y libv4l-dev v4l-utils qv4l2 v4l2ucp libdc1394-22-dev
如果出现errorE: unable to locate libjasper-dev
报错
按如下语句操作即可
sudo add-apt-repository "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe"
sudo apt update
sudo apt install libjasper1 libjasper-dev
参考: https://blog.csdn.net/weixin_41053564/article/details/81254410
下载&解压&创建环境
# Download sources
wget -t 0 -c https://github.com/opencv/opencv/archive/4.1.0.zip
wget -t 0 -c https://github.com/opencv/opencv_contrib/archive/4.1.0.zip
网盘下载链接, 用者自取
链接:opencv-4.1.0
提取码:cdn0
链接:opencv_contrib-4.1.0
提取码:qo9h
# Unzip
unzip opencv-4.1.0.zip
unzip opencv_contrib-4.1.0.zip
mkdir release
cd release/
cmake&make
cmake -D WITH_CUDA=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules \
-D WITH_GSTREAMER=ON \
-D WITH_LIBV4L=ON \
-D BUILD_opencv_python2=ON \
-D BUILD_opencv_python3=ON \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_EXAMPLES=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j2
建议关掉显示器, 不然会内存
make过程中可能会缺少一些文件…
上传一些可能缺少的文件(原则上可以先make -j2 然后看缺什么再传)
下载链接: https://files.cnblogs.com/files/ikic/boostdesc_bgm.i,vgg_generated_48.i%E7%AD%89.rar
通过xftp4上传到: opencv_contrib/modules/xfeatures2d/src/
上传方式见链接: 怎样快速使用Xftp上传下载文件
…done
sudo make install
…done