Jetson agx Xavier上yolov3的安装和测试

Jetson agx Xavier上yolov3的安装和测试

参考创客智造(连接如下)
https://www.ncnynl.com/archives/201903/2899.html
https://www.ncnynl.com/archives/201903/2904.html

xavier上安装opencv3.4

  • 新建目录
mkdir -p ~/tools/
  • 新建文件installOpencv340Xavier.sh
cd ~/tools/
sudo gedit installOpencv340Xavier.sh 
  • 输入如下内容
#!/bin/bash
#
# Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
#
# NVIDIA Corporation and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA Corporation is strictly prohibited.
#


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
sudo apt-get install -y python-dev python-numpy 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-get update

echo "** Download opencv-3.4.0"
curl -L https://github.com/opencv/opencv/archive/3.4.0.zip -o opencv-3.4.0.zip
unzip opencv-3.4.0.zip 
cd opencv-3.4.0/

echo "** Building..."
mkdir release
cd release/
cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="7.2"  -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 ..

make
sudo make install

echo "** Install opencv-3.4.0 successfully"
echo "** Bye :)"
  • 执行安装
sudo chmod +x installOpencv340Xavier.sh 
./installOpencv340Xavier.sh 

安装yolov3

  • 下载源码
mkdir -p ~/dl/darknet
cd ~/dl/darknet
git clone https://github.com/pjreddie/darknet.git
cd darknet
  • 修改Makefile
GPU=1
CUDNN=1
OPENCV=1
OPENMP=1
DEBUG=1

ARCH= -gencode arch=compute_72,code=[sm_72,compute_72]

#cuda路劲
NVCC=/usr/local/cuda-10.2/bin/nvcc
#上面这个是我板子上cuda路劲,根据自己板子进行更改
  • 编译
sudo make -j8 #j后面跟的是自己板子的cpu核数,xavier为8核

编译的过程可能会出现错误,缺少依赖包,按照错误安装完依赖包后先sudo clean在重新编译

  • 判断是否成功
./darknet 

若输出usage: ./darknet 则安装成功

测试yolov3

  • 下载训练好的yolov3模型,下载到darknet下
wget https://pjreddie.com/media/files/yolov3.weights  
  • 测试运行
    data文件中有7张测试照片,任选一张测试即可
./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
./darknet detect cfg/yolov3.cfg yolov3.weights data/eagle.jpg
./darknet detect cfg/yolov3.cfg yolov3.weights data/giraffe.jpg
./darknet detect cfg/yolov3.cfg yolov3.weights data/horses.jpg
./darknet detect cfg/yolov3.cfg yolov3.weights data/kite.jpg
./darknet detect cfg/yolov3.cfg yolov3.weights data/person.jpg
./darknet detect cfg/yolov3.cfg yolov3.weights data/scream.jpg
  • 下载yolov3-tiny模型
wget https://pjreddie.com/media/files/yolov3-tiny.weights
  • 测试视频
    把换成自己的视频名就行,位置一样也是在darknet下,若放置在data下则改为 data/
./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights 

Jetson agx Xavier上yolov3的安装和测试_第1张图片
Jetson agx Xavier上yolov3的安装和测试_第2张图片

#####################更新8.4#####################
yolov3.weights和yolov3-tiny.weights文件下载:

百度网盘提取码:t76q

腾讯微云

你可能感兴趣的:(jetson,agx,xavier,yolov3,opencv,linux,cuda)