NVIDIA Jetson Xavier NX Anyolo v5 +D435i camera pyrealsense2 pro test easy to use

On the third-to-last day of 2021, I finished the environmental part I want to do this semester. With this article, I just commemorate it. It really records what I did in the first stage. Too many, with the attitude of starting over if you can't solve it, you have skipped a lot of things that can't be solved in two or three days. It would be great if there is a statistics on the number of times you use csdn. I feel that I am on csdn every day, even English composition It's all on csdn hahaha, 2022 will be even better.

Goal: Implement the call of yolo v5 and D435i camera on NX

My last article used miniforge to manage the environment. It is true that the environment management is very good, but there are too many versions of python, 4 versions, and it does not respond after I fill in the environment variables. Anyway, I just gave up hahaha, because NX itself has python, opencv and so on. It feels more convenient to do it directly, so it feels super convenient to do it directly.

Reference: Jetson NX + Jetpack4.4 + Ubuntu18.04 to install the PyRealsense package

text:

Brush the machine, configure it, and turn on the fan

sudo sh -c 'echo 140 >/sys/devices/pwm-fan/target_pwm' 

1. Install pyrealsense

At present, there is no PyPi package for pyralsense2 under the arm architecture, so if you use pip to install jetson, you cannot find a satisfactory version, so:

Download the zip package: https://github.com/IntelRealSense/librealsense/releases/

sudo apt-get update  //执行指令更新源
sudo apt-get install -y git libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev   
//安装构建 librealsense 库所需的核心包
sudo apt-get install -y libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev   
//为 Ubuntu 18 安装特定于发行版的软件包
sudo apt-get install python3-dev

Unzip the downloaded zip package, I changed the name and deleted the version number

cd librealsense   //解压后进入librealsense下
//D435i没有与NX连接
./scripts/setup_udev_rules.sh   //执行许可证脚本
mkdir build //创建build目录
cd build     //进入
cmake ../ -DFORCE_RSUSB_BACKEND=ON -DBUILD_PYTHON_BINDINGS:bool=true -DPYTHON_EXECUTABLE=/usr/bin/python3.6 -DCMAKE_BUILD_TYPE=release -DBUILD_EXAMPLES=true -DBUILD_GRAPHICAL_EXAMPLES=true -DBUILD_WITH_CUDA:bool=true
sudo make uninstall   
sudo make clean     
make   //很久很久
sudo make install

An error was reported halfway: no cmake cuda_compiler could be found

solve:

export PATH=/usr/local/cuda/bin:$PATH

Export pyrealsense2 to PYTHONPATH so that import pyrealsense2 works

sudo gedit ~/.bashrc    //打开
//下面三行填进去
export PATH=$PATH:~/.local/bin
export PYTHONPATH=$PYTHONPATH:/usr/local/lib
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/pyrealsense2
//保存,关掉
source /.bashrc

verify:

python3
import pyrealsense2
exit()

2. Install yolo v5 environment

1. Install matplotlib:

sudo apt-get install python3-matplotlib
验证:python3
     import matplotlib as plt
     import numpy as np
     exit()

2. An dependency

sudo apt-get install cmake libopenblas-dev liblapack-dev libjpeg-dev
sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
sudo pip3 install adafruit-circuitpython-servokit
sudo apt-get install python3-pip  //安pip

3. Install torch, torchvision is the same as before

sudo apt-get install python3-pip libopenblas-base libopenmpi-dev
pip3 install Cython  //不安会报错
pip3 install torch-1.7.0-cp36-cp36m-linux_aarch64.whl
git clone -b v0.8.1 https://hub.fastgit.org/pytorch/vision.git
cd vision
sudo python3 setup.py install
报错:error:command ‘gcc' failed with exit status 1
     发现错误再#include <libavcodec/avcodec.h>
改:sudo gedit setup.py
    py文件中的if has ffmeg改为if False
    保存,退出
    再运行,okk

4. Install other

sudo pip3 install tqdm==4.41.0
sudo pip3 install seaborn==0.11.0

Once the environment is safe, just run the py file under python3

There are many errors but I can’t remember. One of them is that the so file of pyrealsense is wrong. Find your own version of the so file. There are six in total. Just copy it. If you encounter an error, bing will always come out. If it still doesn’t work, just flash the machine , start all over again!

After all the problems are solved, the result is the picture below, with a detection frame and an image, it’s over, sprinkle flowers

Guess you like

Origin blog.csdn.net/Zosse/article/details/122211959