nvidia示例

nvidia示例。

安装 deepstream SDK

方法一:使用 sdkmanager

在sdkmanager中选择deepstream,按刷机的方式安装即可。

方法二:单独下载

下载:https://developer.nvidia.com/deepstream-getting-started (要登录)

安装:

1
2
3
4
- CUDA (10.2)
- TensorRT (7.1+)
- OpenCV (3.3.1)
- VisionWorks (1.6)

安装工具:

1
2
3
4
5
6
7
8
9
10
11
$ sudo apt-get install \
libssl1.0.0 \
libgstreamer1.0-0 \
gstreamer1.0-tools \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-alsa \
libgstrtspserver-1.0-0 \
libjansson4

安装:

1
./install.sh
1
2
3
4
5
md5sum deepstream_sdk_v5.0.1_jetson.tbz2 
5c60a89924535129ec3b4997ebbc0f83 deepstream_sdk_v5.0.1_jetson.tbz2

sudo nvpmodel -m 0
sudo jetson_clocks

安装环境后,检查:

1
2
3
4
5
6
7
8
# deepstream-app --version-all 
deepstream-app version 5.0.0
DeepStreamSDK 5.0.0
CUDA Driver Version: 10.2
CUDA Runtime Version: 10.2
TensorRT Version: 7.1
cuDNN Version: 8.0
Dewarper: not found
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
模型文件:/opt/nvidia/deepstream/deepstream-5.0/samples/models

示例文档:https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_ref_app_github.html
示例地址:https://github.com/NVIDIA-AI-IOT/deepstream_reference_apps。克隆其到 /opt/nvidia/deepstream/deepstream_reference_apps。

安装依赖:
查看:/opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-app/README
命令:
sudo apt-get install libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev \
libgstrtspserver-1.0-dev libx11-dev libjson-glib-dev
编译:make (验证SDK、依赖是否完备)。

将 anomaly 拷贝到 /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/ :
cp /opt/nvidia/deepstream/deepstream_reference_apps/anomaly/ /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/

进入目录:
cd /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/anomaly
编译库:
cd plugins/gst-dsdirection/
make && sudo make install

编辑 ./anomaly/apps/deepstream-anomaly-detection-test/dsanomaly_pgie_config.txt 文件。

测试资源:
/opt/nvidia/deepstream/deepstream/samples/streams
/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.h264


gst-launch-1.0 filesrc location = samples/streams/sample_1080p_h264.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! m.sink_0 \
nvstreammux name=m batch-size=1 width=1280 height=720 ! nvinfer config-file-path= samples/configs/deepstream-app/config_infer_primary.txt \
! nvof ! tee name=t ! queue ! nvofvisual ! nvmultistreamtiler width=1920 height=1080 ! nvegltransform ! nveglglessink sync=0 t. ! queue ! dsdirection ! \
nvmultistreamtiler width=1920 height=1080 ! nvvideoconvert ! nvdsosd ! nvegltransform ! nveglglessink sync=0

gst-launch-1.0 -e nvstreammux name=mux batch-size=2 width=1920 height=1080 ! nvinfer config-file-path=/opt/nvidia/deepstream/deepstream-5.0/samples/configs/deepstream-app/config_infer_primary.txt batch-size=2 \
! nvstreamdemux name=demux filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_1080p_h264.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! queue \
! mux.sink_0 filesrc location=/opt/nvidia/deepstream/deepstream-5.0/samples/streams/sample_720p.h264 ! h264parse ! nvv4l2decoder ! queue ! mux.sink_1 demux.src_0 ! "video/x-raw(memory:NVMM), format=NV12" \
! queue ! nvvideoconvert ! "video/x-raw(memory:NVMM), format=RGBA" ! nvdsosd ! nvvideoconvert ! nveglglessink demux.src_1 ! queue ! "video/x-raw(memory:NVMM), format=NV12" ! queue ! nvvideoconvert ! "video/x-raw(memory:NVMM), format=RGBA" ! nvegltransform ! nveglglessink

出错(在图形界面中运行也一样):
nvbuf_utils: Could not get EGL display connection
WARNING: erroneous pipeline: no element "nvstreammux"

2个示例:
cd /opt/nvidia/deepstream/deepstream_reference_apps/anomaly/apps/deepstream-anomaly-detection-test
./deepstream-anomaly-detection-app /opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.h264

cd /opt/nvidia/deepstream/deepstream_reference_apps/back-to-back-detectors
./back-to-back-detectors /opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.h264

出错及解决:

1
2
3
4
5
6
提示:
nvbuf_utils: Could not get EGL display connection:
临时设置环境环境: export DISPLAY=:0

One element could not be created. Exiting.

查看插件:

1
2
3
4
5
6
7
8
9
10

filesrc

gst-inspect-1.0 -a |grep -i NVIDIA

$ gst-inspect-1.0 nvarguscamerasrc
有信息输出

$ gst-inspect-1.0 nvstreammux
No such element or plugin 'nvstreammux'
1
2
3
sudo docker run -it --rm --net=host --runtime nvidia  -e DISPLAY=$DISPLAY -w /opt/nvidia/deepstream/deepstream-5.0 -v /tmp/.X11-unix/:/tmp/.X11-unix -v /opt/nvidia/deepstream/deepstream_reference_apps:/opt/nvidia/deepstream/deepstream_reference_app nvcr.io/nvidia/deepstream-l4t:5.0.1-20.09-samples

sudo docker run -it --rm --net=host --runtime nvidia -e DISPLAY=$DISPLAY -v /tmp/.X11-unix/:/tmp/.X11-unix nvcr.io/nvidia/deepstream-l4t:5.0.1-20.09-base bash

https://github.com/NVIDIA-AI-IOT/redaction_with_deepstream/

安装指南:https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Quickstart.html#jetson-setup