Skip to content

Commit 2931f6b

Browse files
committed
Update to v0.9 release
- Add bindings for image data and tensor metadata. - Add sample apps for image data usage, custom inference output parsing, USB camera source and RTSP output.
1 parent 493a6c0 commit 2931f6b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3006
-130
lines changed

.python-app-pipeline.png

288 KB
Loading

FAQ.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Frequently Asked Questions and Troubleshooting Guide
22

3-
[Application fails to work with mp4 stream](#faq0)
4-
[Ctrl-C does not stop the app during engine file generation](#faq1)
5-
[Application fails to create gst elements](#faq2)
6-
[GStreamer debugging](#faq3)
7-
[Application stuck with no playback](#faq4)
8-
[Error on setting string field](#faq5)
9-
[Pipeline unable to perform at real time](#faq6)
3+
* [Application fails to work with mp4 stream](#faq0)
4+
* [Ctrl-C does not stop the app during engine file generation](#faq1)
5+
* [Application fails to create gst elements](#faq2)
6+
* [GStreamer debugging](#faq3)
7+
* [Application stuck with no playback](#faq4)
8+
* [Error on setting string field](#faq5)
9+
* [Pipeline unable to perform at real time](#faq6)
10+
* [Triton container problems with multi-GPU setup](#faq7)
1011

1112
<a name="faq0"></a>
1213
### Application fails to work with mp4 stream
@@ -93,3 +94,9 @@ The application appears to be stuck without any playback activity.
9394
(info.get_buffer()) from traversing the pipeline until user return.
9495
b) loops inside probe() callback could be costly in python.
9596

97+
<a name="faq7"></a>
98+
### Triton container problems with multi-GPU setup
99+
The Triton Inference Server plugin currently only supports single-GPU usage.
100+
When running the docker, please specify
101+
`--gpus device=<GPU ID>`
102+
e.g.: `--gpus device=0`

HOWTO.md

+34-11
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ This guide provides resources for DeepStream application development in Python.
88
* [Running Sample Applications](#run_samples)
99
* [Pipeline Construction](#pipeline_construction)
1010
* [MetaData Access](#metadata_access)
11+
* [Image Data Access](#imagedata_access)
12+
* [Custom Inference Output Parsing](apps/deepstream-ssd-parser/custom_parser_guide.md)
1113
* [FAQ and Troubleshooting](FAQ.md)
1214

1315
<a name="prereqs"></a>
1416
## Prerequisites
1517

1618
* Ubuntu 18.04
17-
* [DeepStream SDK 4.0.1](https://developer.nvidia.com/deepstream-download) or later
18-
* Python 3
19+
* [DeepStream SDK 5.0 Developer Preview](https://developer.nvidia.com/deepstream-download) or later
20+
* Python 3.6
1921
* [Gst Python](https://gstreamer.freedesktop.org/modules/gst-python.html) v1.14.5
2022

2123
Gst python should be already installed on Jetson.
@@ -36,11 +38,11 @@ If missing, install with the following steps:
3638
<a name="run_samples"></a>
3739
## Running Sample Applications
3840

39-
Download the release package and unpack it under DS 4.0.1 installation:
40-
```tar xf ds_pybind_0.5.tbz2 -C <DeepStream 4.0.1 ROOT>/sources```
41+
Download the release package and unpack it under DS 5.0 installation:
42+
```tar xf ds_pybind_v0.9.tbz2 -C <DeepStream 5.0 ROOT>/sources```
4143

4244
This will create the following directory:
43-
```<DeepStream 4.0.1 ROOT>/sources/python```
45+
```<DeepStream 5.0 ROOT>/sources/python```
4446

4547
The Python apps and bindings are under the "python" directory.
4648
Go into each app directory and follow instructions in the README.
@@ -56,7 +58,7 @@ See [sample applications](apps/) main functions for pipeline construction exampl
5658
<a name="metadata_access"></a>
5759
## MetaData Access
5860

59-
DeepStream MetaData contains inference results and other information used in analytics. The MetaData is attached to the Gst Buffer received by each pipeline component. The metadata format is described in detail in the [SDK MetaData documentation](https://docs.nvidia.com/metropolis/deepstream/plugin-manual/index.html#page/DeepStream_Plugin_Manual%2Fdeepstream_plugin_metadata.03.1.html) and [API Guide](https://docs.nvidia.com/metropolis/deepstream/dev-guide/DeepStream_Development_Guide/baggage/group__metadata__structures.html).
61+
DeepStream MetaData contains inference results and other information used in analytics. The MetaData is attached to the Gst Buffer received by each pipeline component. The metadata format is described in detail in the [SDK MetaData documentation](https://docs.nvidia.com/metropolis/deepstream/plugin-manual/index.html#page/DeepStream_Plugin_Manual%2Fdeepstream_plugin_metadata.03.1.html) and [API Guide](https://docs.nvidia.com/metropolis/deepstream/python-api/index.html).
6062

6163
The SDK MetaData library is developed in C/C++. Python bindings provide access to the MetaData from Python applications. The bindings are provided in a compiled module, available for x86_64 and Jetson platforms. Find them in the release package with the following layout:
6264
```
@@ -118,10 +120,12 @@ This will cause a memory buffer to be allocated, and the string "TYPE" will be c
118120
This memory is owned by the C code and will be freed later. To free the buffer in Python code, use:
119121
```pyds.free_buffer(obj.type)```
120122

123+
NOTE: NvOSD_TextParams.display_text string now gets freed automatically when a new string is assigned.
124+
121125
##### Reading String Fields
122126
Directly reading a string field returns C address of the field in the form of an int, e.g.:
123127
```python
124-
obj = pyds.glist_get_nvds_vehicle_object(data);
128+
obj = pyds.NvDsVehicleObject.cast(data);
125129
print(obj.type)
126130
```
127131
This will print an int representing the address of obj.type in C (which is a char*).
@@ -133,25 +137,38 @@ print(pyds.get_string(obj.type))
133137

134138
#### Casting
135139

136-
Some MetaData instances are stored in GList form. To access the data in a GList node, the data field needs to be cast to the appropriate structure. This casting is done via binding functions:
140+
Some MetaData instances are stored in GList form. To access the data in a GList node, the data field needs to be cast to the appropriate structure. This casting is done via cast() member function for the target type:
141+
```python
142+
NvDsBatchMeta.cast
143+
NvDsFrameMeta.cast
144+
NvDsObjectMeta.cast
145+
NvDsUserMeta.cast
146+
NvDsClassifierMeta.cast
147+
NvDsDisplayMeta.cast
148+
NvDsLabelInfo.cast
149+
NvDsEventMsgMeta.cast
150+
NvDsVehicleObject.cast
151+
NvDsPersonObject.cast
152+
```
153+
154+
In version v0.5, standalone cast functions were provided. Those are now deprecated and superseded by the cast() functions above:
137155
```python
138156
glist_get_nvds_batch_meta
139157
glist_get_nvds_frame_meta
140158
glist_get_nvds_object_meta
141-
glist_get_nvds_user_met
159+
glist_get_nvds_user_meta
142160
glist_get_nvds_classifier_meta
143161
glist_get_nvds_display_meta
144162
glist_get_nvds_label_info
145163
glist_get_nvds_event_msg_meta
146-
glist_get_nvds_event_msg_meta
147164
glist_get_nvds_vehicle_object
148165
glist_get_nvds_person_object
149166
```
150167

151168
Example:
152169
```python
153170
l_frame = batch_meta.frame_meta_list
154-
frame_meta = pyds.glist_get_nvds_frame_meta(l_frame.data)
171+
frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
155172
```
156173

157174
#### Callback Function Registration
@@ -193,3 +210,9 @@ These are performend on each object in deepstream_test_4.py, causing the aggrega
193210

194211
This function populates the input buffer with a timestamp generated according to RFC3339:
195212
```%Y-%m-%dT%H:%M:%S.nnnZ\0```
213+
214+
<a name="imagedata_access"></a>
215+
## Image Data Access
216+
217+
Decoded images are accessible as NumPy arrays via the `get_nvds_buf_surface` function. This function is documented in the [API Guide](https://docs.nvidia.com/metropolis/deepstream/5.0/python-api/index.html).
218+
Please see the [deepstream-imagedata-multistream](apps/deepstream-imagedata-multistream) sample application for an example of image data usage.

README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
This repository contains Python bindings and sample applications for the [DeepStream SDK](https://developer.nvidia.com/deepstream-sdk).
44

5-
The bindings and apps are currently in *Alpha* at [v0.5](../..//releases/tag/v0.5-alpha). API changes are expected in future releases.
6-
SDK version supported: 4.0.1
5+
The bindings and apps are currently in *Alpha* at v0.9. The API is maturing but changes are still expected.
6+
SDK version supported: 5.0 Developer Preview
77

88
Download the latest release package complete with bindings and sample applications from the [release section](../../releases).
99

@@ -19,11 +19,11 @@ DeepStream pipelines can be constructed using Gst Python, the GStreamer framewor
1919
Python bindings are provided in the form of a compiled module. Download these bindings [here](https://developer.nvidia.com/deepstream-download#python_bindings). This module is generated using [Pybind11](https://github.com/pybind/pybind11).
2020

2121
<p align="center">
22-
<img src=".python-app-pipeline.png" alt="bindings pipeline" height="400px"/>
22+
<img src=".python-app-pipeline.png" alt="bindings pipeline" height="600px"/>
2323
</p>
2424

2525
These bindings support a Python interface to the MetaData structures and functions. Usage of this interface is documented in the [HOW-TO Guide](HOWTO.md) and demonstrated in the sample applications.
26-
The current bindings are limited to the [NvDsBatchMeta](https://docs.nvidia.com/metropolis/deepstream/plugin-manual/index.html#page/DeepStream_Plugin_Manual%2Fdeepstream_plugin_metadata.03.2.html%23) hierarchy. Image data access is currently not included.
26+
This release adds bindings for decoded image buffers (NvBufSurface) as well as inference output tensors (NvDsInferTensorMeta).
2727

2828
<a name="sample_applications"></a>
2929
## Sample Applications
@@ -37,13 +37,15 @@ To run the sample applications or write your own, please consult the [HOW-TO Gui
3737
<img src=".test3-app.png" alt="deepstream python app screenshot" height="400px"/>
3838
</p>
3939

40-
We currently provide four sample applications:
40+
We currently provide the following sample applications:
4141
* [deepstream-test1](apps/deepstream-test1) -- 4-class object detection pipeline
4242
* [deepstream-test2](apps/deepstream-test2) -- 4-class object detection, tracking and attribute classification pipeline
4343
* [deepstream-test3](apps/deepstream-test3) -- multi-stream pipeline performing 4-class object detection
4444
* [deepstream-test4](apps/deepstream-test4) -- msgbroker for sending analytics results to the cloud
45-
46-
These are Python versions of the first four test applications included in the DeepStream SDK.
45+
* [deepstream-imagedata-multistream](apps/deepstream-imagedata-multistream) -- multi-stream pipeline with access to image buffers
46+
* [deepstream-ssd-parser](apps/deepstream-ssd-parser) -- SSD model inference via Triton server with output parsing in Python
47+
* [deepstream-test1-usbcam](apps/deepstream-test1-usbcam) -- deepstream-test1 pipelien with USB camera input
48+
* [deepstream-test1-rtsp-out](apps/deepstream-test1-rtsp-out) -- deepstream-test1 pipeline with RTSP output
4749

4850
Detailed application information is provided in each application's subdirectory under [apps](apps).
4951

apps/README

+39-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
################################################################################
2-
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
2+
# Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
33
#
44
# Permission is hereby granted, free of charge, to any person obtaining a
55
# copy of this software and associated documentation files (the "Software"),
@@ -25,8 +25,8 @@ DeepStream SDK Python Bindings
2525
================================================================================
2626
Setup pre-requisites:
2727
- Ubuntu 18.04
28-
- DeepStream SDK 4.0.1
29-
- Python 3
28+
- NVIDIA DeepStream SDK 5.0 Developer Preview
29+
- Python 3.6
3030
- Gst-python
3131

3232
--------------------------------------------------------------------------------
@@ -42,43 +42,39 @@ The DeepStream Python package includes:
4242
|- jetson
4343
|- pyds.so
4444
2. DeepStream test apps in Python
45-
Four test apps are available:
46-
deepstream-test1/deepstream_test_1.py
47-
deepstream-test2/deepstream_test_2.py
48-
deepstream-test3/deepstream_test_3.py
49-
deepstream-test3/deepstream_test_4.py
45+
The following test apps are available:
46+
deepstream-test1
47+
deepstream-test2
48+
deepstream-test3
49+
deepstream-test4
50+
deepstream-imagedata-multistream
51+
deepstream-ssd-parser
52+
deepstream-test1-rtsp-out
53+
deepstream-test1-usbcam
5054

5155
--------------------------------------------------------------------------------
5256
Installing Pre-requisites:
5357
--------------------------------------------------------------------------------
5458

55-
DeepStream SDK 4.0.1
59+
DeepStream SDK 5.0 Developer Preview
5660
--------------------
5761
Download and install from https://developer.nvidia.com/deepstream-download
5862

59-
Python 3
63+
Python 3.6
6064
----------
6165
Should be already installed with Ubuntu 18.04
6266

6367
Gst-python
6468
----------
6569
Should be already installed on Jetson
6670
If missing, install with the following steps:
67-
$ sudo apt-get install python-gi-dev
68-
$ export GST_LIBS="-lgstreamer-1.0 -lgobject-2.0 -lglib-2.0"
69-
$ export GST_CFLAGS="-pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include"
70-
$ git clone https://github.com/GStreamer/gst-python.git
71-
$ cd gst-python
72-
$ git checkout 1a8f48a
73-
$ ./autogen.sh PYTHON=python3
74-
$ ./configure PYTHON=python3
75-
$ make
76-
$ sudo make install
71+
$ sudo apt update
72+
$ sudo apt install python3-gi python3-dev python3-gst-1.0 -y
7773

7874
--------------------------------------------------------------------------------
7975
Running the samples
8076
--------------------------------------------------------------------------------
81-
The apps are configured to work from inside the DeepStream SDK 4.0.1 installation.
77+
The apps are configured to work from inside the DeepStream SDK 5.0 installation.
8278
Untar the contents into <DeepStream install root>/sources/.
8379

8480
Note that the apps import the pyds module from this relative path:
@@ -90,9 +86,30 @@ Example: running test1 app:
9086
$ cd deepstream-test1
9187
$ python3 deepstream_test_1.py <input .h264 file>
9288

89+
--------------------------------------------------------------------------------
90+
Running the samples inside DeepStream SDK docker
91+
--------------------------------------------------------------------------------
92+
The general steps are:
93+
1. Pull the DeepStream SDK docker of choice following the latest DeepStream
94+
Release Notes at https://developer.nvidia.com/deepstream-sdk for more info.
95+
Note that the deepstream-ssd-parser app requires the Triton docker on x86_64.
96+
2. Run the docker with Python Bindings mapped using the following option:
97+
-v <path to this python bindings directory>:/opt/nvidia/deepstream/deepstream-5.0/sources/python
98+
3. Inside the container, install packages required by all samples:
99+
$ sudo apt update
100+
$ sudo apt install python3-gi python3-dev python3-gst-1.0 -y
101+
4. Optionally install additional dependencies required by specific samples.
102+
See README in app's directory for such requirements.
103+
$ sudo apt install python3-opencv
104+
$ sudo apt install python3-numpy
105+
$ sudo apt install libgstrtspserver-1.0-0 gstreamer1.0-rtsp
106+
$ sudo apt install libgirepository1.0-dev
107+
$ sudo apt install gobject-introspection gir1.2-gst-rtsp-server-1.0
108+
5. Run sample apps following directions in each app's README.
109+
93110
--------------------------------------------------------------------------------
94111
Notes:
95112
--------------------------------------------------------------------------------
96113
As with DeepStream SDK, if the application runs into errors, cannot create gst elements,
97114
try again after removing gstreamer cache
98-
rm ${HOME}/.cache/gstreamer-1.0/registry.x86_64.bin
115+
rm ${HOME}/.cache/gstreamer-1.0/*

apps/common/FPS.py

+22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
################################################################################
2+
# Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a
5+
# copy of this software and associated documentation files (the "Software"),
6+
# to deal in the Software without restriction, including without limitation
7+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
# and/or sell copies of the Software, and to permit persons to whom the
9+
# Software is furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
# DEALINGS IN THE SOFTWARE.
21+
################################################################################
22+
123
import time
224
start_time=time.time()
325
frame_count=0

apps/common/bus_call.py

+22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
################################################################################
2+
# Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a
5+
# copy of this software and associated documentation files (the "Software"),
6+
# to deal in the Software without restriction, including without limitation
7+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
# and/or sell copies of the Software, and to permit persons to whom the
9+
# Software is furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
# DEALINGS IN THE SOFTWARE.
21+
################################################################################
22+
123
import gi
224
import sys
325
gi.require_version('Gst', '1.0')

apps/common/is_aarch_64.py

+26-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
1+
################################################################################
2+
# Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a
5+
# copy of this software and associated documentation files (the "Software"),
6+
# to deal in the Software without restriction, including without limitation
7+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
# and/or sell copies of the Software, and to permit persons to whom the
9+
# Software is furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
# DEALINGS IN THE SOFTWARE.
21+
################################################################################
22+
123
import platform
224
import sys
25+
26+
327
def is_aarch64():
4-
machine = platform.uname()[4]
5-
if machine in ['aarch64']:
6-
return True
7-
else:
8-
return False
28+
return platform.uname()[4] == 'aarch64'
929

10-
if is_aarch64():
11-
sys.path.append('../../bindings/jetson')
12-
else:
13-
sys.path.append('../../bindings/x86_64')
1430

31+
sys.path.append('../../bindings/' + ('jetson' if is_aarch64() else 'x86_64'))

0 commit comments

Comments
 (0)