Detailed steps to install OpenCV 3.2.0 on Jetson Nano

Table of Contents

1 Overview and preparation

1.1 Overview

1.2 Mirror and source code download address

1.3 Change the source of Ubuntu 18.04

2 Install OpenCV3.2.0

2.1 Remove CUDA/OpenCV 4.1.1

2.2 Update the latest list of software packages & update packages

2.3 Install dependencies

2.3.1 Change source

2.3.2 Update package list

2.3.3 Install libjasper-dev

2.4 Create OpenCV 3.2.0 directory

2.4.1 Create the main installation directory and decompression directory

2.4.2 Create compilation directory

2.4.3 Directory composition

2.5 Compile source code

2.5.1 Replace download address

2.5.1.1 Failed to download related files

2.5.1.2 Failed to download related files

2.5.2 Configuring OpenCV

2.5.3 Compile and install OpenCV

2.6 OpenCV environment configuration

2.6.1 Create OpenCV library

2.6.2 Make the opencv configuration file effective

2.6.3 Configure bash environment variables

2.6.4 Verify whether opencv is installed successfully:

3 Reference articles


1 Overview and Preparation

1.1 Overview

For the Jetson Nano development board, the OpenCV 4.1.1 that comes with the official image provided by NVIDIA is incompatible with many programs. This article combines the experience of multiple CSDN articles to provide a way to install OpenCV 3.2.0 under the official image. method.

Note: It is recommended to install OpenCV 3.2.0 first after installing a pure system and changing the source. It is not recommended to replace the OpenCV version after installing ROS.

1.2 Image and source code download address

Hardware: Jetson Nano (with 4G RAM)

software:

1. Jetson Nano official Ubuntu 18.04 image Jetson Nano Developer Kit SD Card Imageicon-default.png?t=N7T8https://developer.nvidia.com/embedded/l4t/r32_release_v6.1/jeston_nano /jetson-nano-jp46-sd-card-image.zip2.OpenCV 3.2.0 & amp; OpenCV-contrib-3.2.0
OpenCV 3.2.0icon-default.png?t=N7T8https://github.com/opencv/opencv/archive/3.2.0.zip

OpenCV-contrib-3.2.0icon-default.png?t=N7T8https://github.com/opencv/opencv_contrib/archive/refs/tags/3.2.0.zip

1.3 Change source to Ubuntu 18.04

It is recommended to use Yuxiang ROS to change the source with one click, which can quickly change to a suitable domestic image source.

wget http://fishros.com/install -O fishros & amp; & amp; . fishros

Note: Just change the source and do not install ROS.

2 Install OpenCV3.2.0

2.1 Delete CUDA/OpenCV 4.1.1

dpkg -l | grep -i cudnn
sudo apt-get remove cuda*
sudo apt-get remove libnvinfer*
sudo apt-get remove libcudnn8*
sudo apt-get remove libopencv*
sudo apt-get remove libvisio*

Note: At this time, many packages that may be needed for future development will be deleted, such as curl, etc. Just install it when you need to use it later.

2.2 Update the latest list of software packages & update software packages

sudo apt-get update
sudo apt-get upgrade

2.3 Installation dependencies

sudo apt-get install cmake libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg-dev libpng-dev libtiff-dev libtiff5-dev libswscale-dev libcurl4-openssl-dev libtbb2 libdc1394-22-dev

There is also a dependency that is not installed at this time. You need to change the source before installing.

2.3.1 Change source

Open sources.list using the following command:

sudo gedit /etc/apt/sources.list

Delete everything in sources.list and add the following:

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe

2.3.2 Update software package list

sudo apt-get update

2.3.3 Install libjasper-dev

sudo apt-get install libjasper1 libjasper-dev --fix-missing

2.4 Create OpenCV 3.2.0 directory

2.4.1 Create the main installation directory and decompression directory

Create the folder OpenCV in the home directory

Open a terminal and enter:

mkdir ~/OpenCV

Extract the downloaded opencv-3.2.0.zip and opencv_contrib-3.2.0.zip into folders into the folder you just created.

2.4.2 Create compilation directory

Open a terminal and enter:

mkdir ~/OpenCV/opencv-3.2.0/build
mkdir ~/OpenCV/opencv-3.2.0_install

Create two compilation folders

2.4.3 Directory composition

At this point, the installation and compilation directories have been set up, and an intuitive tree diagram is now given.

/home/<user>
└─OpenCV
    ├─opencv-3.2.0
    │ ├─build
    │ └─...
    ├─opencv-3.2.0_install
    └─opencv_contrib-3.2.0
        └─...

2.5 compiled source code

2.5.1 Replace download address

Due to network environment reasons, some files during the cmake process may fail to link to the download address, causing cmake to fail.

Let’s replace some file download addresses first.

Open the terminal, enter the following content, and open the corresponding cmake file:

sudo gedit ~/OpenCV/opencv_contrib-3.2.0/modules/xfeatures2d/cmake/download_vgg.cmake

Change raw.githubusercontent.com to raw.staticdn.net, save and close the gedit editor.

2.5.2 Configure OpenCV

Open a terminal and enter:

#Go to the build folder
cd ~/OpenCV/opencv-3.2.0/build
#Execute cmake
cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="7.2" -D ENABLE_PRECOMPILED_HEADERS=OFF -D CUDA_ARCH_PTX="" -D WITH_GSTREAMER=ON -D WITH_LIBV4L=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_EXTRA_MODULES_PATH=~/OpenCV/opencv_contrib-3.2.0/modules ..

It takes a long time to execute cmake, so wait patiently.

2.5.3 Compile and install OpenCV

cd ~/OpenCV/opencv-3.2.0/build
sudo make -j4
sudo make install

The execution takes a long time, please wait a little longer~

2.6 OpenCV environment configuration

2.6.1 Create OpenCV library

Create the opencv.conf file, open the terminal and enter:

sudo gedit /etc/ld.so.conf.d/opencv.conf

Save and close the gedit editor after adding the following content to the file:

/usr/local/lib

2.6.2 Validate the opencv configuration file

Open a terminal and enter:

sudo ldconfig

2.6.3 Configure bash environment variables

Open the .bashrc file and enter in the terminal:

sudo gedit ~/.bashrc

Add at the end of the file:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

Save and close the gedit editor.

Enter in the terminal:

source ~/.bashrc

2.6.4 Verify whether opencv is installed successfully:

Open a terminal and enter:

pkg-config --modversion opencv

If the installation is successful, the terminal should reply:

3.2.0

At this point, OpenCV 3.2.0 installation is complete

3 reference articles

BC!. jeston nano installs opencv3.2[EB/OL]. 2023[2023/10/18].

Tigger’s spring will never rust. Install opencv3.2.0[EB/OL] on ubuntu18.04. 2023[2023/10/18].

A thousand miles of progress. Detailed explanation of installing openCV3.2.0 on ubuntu18.04 (additional source code + third-party library) [EB/OL]. 2022[2023/10/18].

Yilien10. Some files failed to download online, causing opencv to fail cmake [EB/OL]. 2020[2023/10/18].

The knowledge points of the article match the official knowledge files, and you can further learn related knowledge. OpenCV skill treeOpenCV basicsOpenCV installation 23442 people are learning the system