Jetson一键安装opencv4.1.0+opencv4.1.0_contrib

突然想着装一个OPENCV4.1顺便写个记录 

温馨提示:网不行的话就先把这几个文件git pull下来

git clone https://github.com/Unlicensed-driver-ljx/opencv_contrib_essential_module.git
/opencv_contrib-4.1.0/modules/xfeatures2d/src

 放到你的这个目录下再编译,一般有上网方法的同学可以略过

sudo apt-get purge libopencv*
looking for ccache --not found

sudo apt-get install ccache

sudo apt-get install libtesseract-dev
下面的脚本installopencv41.sh和创建的OPENCV放一个目录就好了
mkdir OPENCV
举个例子遇到同学不知道脚本的意思

if [ "$#" -ne 1 ]; then
    echo "Usage: $0 "
    exit
fi
folder="$1"
这里的执行方式是你的脚本改成可执行权限以后,

sudo chmod 777 installopencv41.sh 

sudo ./installopencv41.sh 你的新建的目录(可以是新建的任何名称比如:opencv41)

#!/bin/bash

#Before installing on Nano need to increase memory. Can use swapfile to virtually increase.
#Run these commands to add swap file

if [ "$#" -ne 1 ]; then
    echo "Usage: $0 "
    exit
fi
folder="$1"

echo "** Install requirement"
sudo apt-get update
sudo apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt-get install -y python2.7-dev python3.6-dev python-dev python-numpy python3-numpy
sudo apt-get install -y libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt-get install -y libv4l-dev v4l-utils qv4l2 v4l2ucp
sudo apt-get install -y curl
sudo apt install -y python3-pip
sudo apt-get update

echo "** Download opencv-4.1.0"
cd $folder
wget https://github.com/opencv/opencv/archive/4.1.0.zip -O opencv-4.1.0.zip
wget https://github.com/opencv/opencv_contrib/archive/4.1.0.zip -O opencv-contrib-4.1.0.zip
unzip opencv-4.1.0.zip
unzip opencv-contrib-4.1.0.zip
cd opencv-4.1.0/

echo "** Building make install..."
mkdir release
cd release/
cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3" -D CUDA_ARCH_PTX="" -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 -D OPENCV_GENERATE_PKGCONFIG=ON ..
#(注意 -D OPENCV_GENERATE_PKGCONFIG=ON 这个选项非常重要,会生成一个被pkg-config模块使用的opencv4.pc文件,编译opencv的c++项目时可能会用到,有得同学安装完编译qt项目遇到所以补充了一下)
make -j6
sudo make install
sudo apt-get install -y python-opencv python3-opencv
sudo apt-get install -y libjpeg-dev
sudo pip3 install --user pillow

echo "** Installation opencv-4.1.0 complete"


 

你可能感兴趣的:(jetson_nx,nvidia,ubuntu,运维)