Skip to content

Commit b85789d

Browse files
authored
Merge branch 'NVIDIA-AI-IOT:master' into master
2 parents e40b952 + cb7fd9c commit b85789d

178 files changed

Lines changed: 9513 additions & 4150 deletions

File tree

Some content is hidden

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

.gitmodules

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
[submodule "3rdparty/pybind11"]
2-
path = 3rdparty/pybind11
1+
[submodule "bindings/3rdparty/pybind11"]
2+
path = bindings/3rdparty/pybind11
33
url = https://github.com/pybind/pybind11.git
4-
[submodule "3rdparty/gst-python"]
5-
path = 3rdparty/gst-python
6-
url = https://github.com/GStreamer/gst-python.git
4+
[submodule "bindings/3rdparty/git-partial-submodule"]
5+
path = bindings/3rdparty/git-partial-submodule
6+
url = https://github.com/Reedbeta/git-partial-submodule.git
7+
[submodule "bindings/3rdparty/gstreamer"]
8+
path = bindings/3rdparty/gstreamer
9+
url = https://github.com/GStreamer/gstreamer.git
10+
sparse-checkout = subprojects/gst-python/

3rdparty/gst-python

Lines changed: 0 additions & 1 deletion
This file was deleted.

3rdparty/pybind11

Lines changed: 0 additions & 1 deletion
This file was deleted.

FAQ.md

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,55 @@
11
# Frequently Asked Questions and Troubleshooting Guide
22

3-
* [Git clone fails due to Gstreamer repo access error](#faq9)
4-
* [Application fails to work with mp4 stream](#faq0)
5-
* [Ctrl-C does not stop the app during engine file generation](#faq1)
6-
* [Application fails to create gst elements](#faq2)
7-
* [GStreamer debugging](#faq3)
8-
* [Application stuck with no playback](#faq4)
9-
* [Error on setting string field](#faq5)
10-
* [Pipeline unable to perform at real time](#faq6)
11-
* [Triton container problems with multi-GPU setup](#faq7)
12-
* [ModuleNotFoundError: No module named 'pyds'](#faq8)
3+
- [Frequently Asked Questions and Troubleshooting Guide](#frequently-asked-questions-and-troubleshooting-guide)
4+
- [App causes Jetson Orin Nano to freeze and reboot](#app-causes-jetson-orin-nano-to-freeze-and-reboot)
5+
- [Using new gst-nvstreammux](#using-new-gst-nvstreammux)
6+
- [Git clone fails due to Gstreamer repo access error](#git-clone-fails-due-to-gstreamer-repo-access-error)
7+
- [Application fails to work with mp4 stream](#application-fails-to-work-with-mp4-stream)
8+
- [Ctrl-C does not stop the app during engine file generation](#ctrl-c-does-not-stop-the-app-during-engine-file-generation)
9+
- [Application fails to create gst elements](#application-fails-to-create-gst-elements)
10+
- [GStreamer debugging](#gstreamer-debugging)
11+
- [Application stuck with no playback](#application-stuck-with-no-playback)
12+
- [Error on setting string field](#error-on-setting-string-field)
13+
- [Pipeline unable to perform at real time](#pipeline-unable-to-perform-at-real-time)
14+
- [Triton container problems with multi-GPU setup](#triton-container-problems-with-multi-gpu-setup)
15+
- [ModuleNotFoundError: No module named 'pyds'](#modulenotfounderror-no-module-named-pyds)
16+
17+
<a name="faq11"></a>
18+
### App causes Jetson Orin Nano to freeze and reboot
19+
Most of the DeepStream Python apps are written to use hardware encoders. The Jetson Orin Nano does not have any hardware encoders, so the app must be modified to use software encoders in the pipeline. Please see [deepstream-test1-rtsp-out](./apps/deepstream-test1-rtsp-out/deepstream_test_1_rtsp_out.py):
20+
```python
21+
if codec == "H264":
22+
encoder = Gst.ElementFactory.make("nvv4l2h264enc", "encoder")
23+
if enc_type == 0: # HW encoder
24+
encoder = Gst.ElementFactory.make("nvv4l2h264enc", "encoder")
25+
else: # SW encoder
26+
encoder = Gst.ElementFactory.make("x264enc", "encoder")
27+
```
28+
29+
<a name="faq10"></a>
30+
### Using new gst-nvstreammux
31+
Most DeepStream Python apps are written to use the default nvstreammux and have lines of code written to set nvstreammux properties which are deprecated in the new gst-nvstreammux. See the [DeepStream documentation](https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvstreammux2.html) for more information on the new gst-nvstreammux plugin. To use the new nvstreammux, set the `USE_NEW_NVSTREAMMUX` environment variable before running the app. For example:
32+
```bash
33+
$ export USE_NEW_NVSTREAMMUX="yes"
34+
$ python3 deepstream_test_1.py ../../../../samples/streams/sample_720p.h264
35+
```
36+
The app itself must be modified not to set deprecated properties when using the new nvstreammux. See [deepstream-test1](./apps/deepstream-test1/deepstream_test_1.py):
37+
```python
38+
if os.environ.get('USE_NEW_NVSTREAMMUX') != 'yes': # Only set these properties if not using new gst-nvstreammux
39+
streammux.set_property('width', 1920)
40+
streammux.set_property('height', 1080)
41+
streammux.set_property('batched-push-timeout', 4000000)
42+
```
43+
44+
Running apps without this modification will result in such an error:
45+
```
46+
Traceback (most recent call last):
47+
File "deepstream_test_1.py", line 255, in <module>
48+
sys.exit(main(sys.argv))
49+
File "deepstream_test_1.py", line 194, in main
50+
streammux.set_property('width', 1920)
51+
TypeError: object of type `GstNvStreamMux' does not have property `width'
52+
```
1353

1454
<a name="faq9"></a>
1555
### Git clone fails due to Gstreamer repo access error
@@ -43,9 +83,9 @@ https://docs.python.org/3/library/signal.html
4383
To work around this:
4484
1. Use ctrl-z to bg the process
4585
2. Optionally run "jobs" if there are potentially multiple bg processes:
46-
$ jobs
47-
[1]- Stopped python3 deepstream_test_1.py /opt/nvidia/deepstream/deepstream-4.0/samples/streams/sample_720p.h264 (wd: /opt/nvidia/deepstream/deepstream-4.0/sources/apps/python/deepstream-test1)
48-
[2]+ Stopped python3 deepstream_test_2.py /opt/nvidia/deepstream/deepstream-4.0/samples/streams/sample_720p.h264
86+
$ jobs
87+
[1]- Stopped python3 deepstream_test_1.py /opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.h264 (wd: /opt/nvidia/deepstream/deepstream-4.0/sources/apps/python/deepstream-test1)
88+
[2]+ Stopped python3 deepstream_test_2.py /opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.h264
4989
3. Kill the bg job:
5090
$ kill %<job number, 1 or 2 from above. e.g. kill %1>
5191

@@ -125,5 +165,5 @@ The pyds wheel installs the pyds.so library where all the pip packages are store
125165

126166
Command to install the pyds wheel is:
127167
```bash
128-
$ pip3 install ./pyds-1.1.0-py3-none*.whl
129-
```
168+
$ pip3 install ./pyds-1.2.0*.whl
169+
```

HOWTO.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ This guide provides resources for DeepStream application development in Python.
1515
<a name="prereqs"></a>
1616
## Prerequisites
1717

18-
* Ubuntu 20.04
19-
* [DeepStream SDK 6.1.1](https://developer.nvidia.com/deepstream-download) or later
20-
* Python 3.8
21-
* [Gst Python](https://gstreamer.freedesktop.org/modules/gst-python.html) v1.16.2
18+
* Ubuntu 22.04
19+
* [DeepStream SDK 7.1](https://developer.nvidia.com/deepstream-download) or later
20+
* Python 3.10
21+
* [Gst Python](https://gstreamer.freedesktop.org/modules/gst-python.html) v1.20.3
2222

2323
Gst python should be already installed on Jetson.
2424
If missing, install with the following steps:
@@ -46,11 +46,11 @@ Note: Compiling bindings now also generates a pip installable python wheel for t
4646
<a name="run_samples"></a>
4747
## Running Sample Applications
4848

49-
Clone the deepstream_python_apps repo under <DeepStream 6.1.1 ROOT>/sources:
49+
Clone the deepstream_python_apps repo under <DeepStream ROOT>/sources:
5050
git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps
5151

5252
This will create the following directory:
53-
```<DeepStream 6.1.1 ROOT>/sources/deepstream_python_apps```
53+
```<DeepStream ROOT>/sources/deepstream_python_apps```
5454

5555
The Python apps are under the "apps" directory.
5656
Go into each app directory and follow instructions in the README.
@@ -84,12 +84,12 @@ Memory for MetaData is shared by the Python and C/C++ code paths. For example, a
8484

8585
#### Allocations
8686

87-
When MetaData objects are allocated in Python, an allocation function is provided by the bindings to ensure proper memory ownership of the object. If the constructor is used, the the object will be claimed by the garbage collector when its Python references terminate. However, the object will still need to be accessed by C/C++ code downstream, and therefore must persist beyond those Python references.
87+
When MetaData objects are allocated in Python, an allocation function is provided by the bindings to ensure proper memory ownership of the object. If the constructor is used, the object will be claimed by the garbage collector when its Python references terminate. However, the object will still need to be accessed by C/C++ code downstream, and therefore must persist beyond those Python references.
8888

8989
Example:
9090
To allocate an NvDsEventMsgMeta instance, use this:
9191
```python
92-
msg_meta = pyds.alloc_nvds_event_msg_meta() # get reference to allocated instance without claiming memory ownership
92+
msg_meta = pyds.alloc_nvds_event_msg_meta(user_event_meta) # get reference to allocated instance without claiming memory ownership
9393
```
9494
NOT this:
9595
```python
@@ -173,16 +173,21 @@ frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
173173

174174
Custom MetaData added to NvDsUserMeta require custom copy and release functions. The MetaData library relies on these custom functions to perform deep-copy of the custom structure, and free allocated resources. These functions are registered as callback function pointers in the NvDsUserMeta structure.
175175

176-
Callback functions are registered using these functions:
176+
##### Deprecation Warning
177+
Previously, Callback functions were registered using these functions:
177178
```python
178179
pyds.set_user_copyfunc(NvDsUserMeta_instance, copy_function)
179180
pyds.set_user_releasefunc(NvDsUserMeta_instance, free_func)
180181
```
181182

182-
*NOTE*: Callbacks need to be unregistered with the bindings library before the application exits. The bindings library currently keeps global references to the registered functions, and these cannot last beyond bindings library unload which happens at application exit. Use the following function to unregister all callbacks:
183+
These are now DEPRECATED and are replaced by similar implementation in the binding itself. These are event_msg_meta_copy_func() and event_msg_meta_release_func() respectively. These can be found inside [bindschema.cpp](bindings/src/bindschema.cpp)
184+
185+
##### Deprecation Warning
186+
*NOTE*: Previously, callbacks needed to be unregistered with the bindings library before the application exits. The bindings library currently keeps global references to the registered functions, and these cannot last beyond bindings library unload which happens at application exit. Use the following function to unregister all callbacks:
183187
```pyds.unset_callback_funcs()```
188+
These callbacks are automatically set inside the alloc_nvds_event_msg_meta() function and should NOT be set from the python application (e.g. deepstream-test4)
184189

185-
See the deepstream-test4 sample application for an example of callback registration and unregistration.
190+
The deepstream-test4 sample application has been updated to show an example of removal of these callback registration and unregistration.
186191

187192
Limitation: the bindings library currently only supports a single set of callback functions for each application. The last registered function will be used.
188193

@@ -212,5 +217,5 @@ This function populates the input buffer with a timestamp generated according to
212217
<a name="imagedata_access"></a>
213218
## Image Data Access
214219

215-
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/6.0.1/python-api/index.html).
220+
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/dev-guide/python-api/index.html).
216221
Please see the [deepstream-imagedata-multistream](apps/deepstream-imagedata-multistream) sample application for an example of image data usage.

README.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,35 @@
22

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

5-
SDK version supported: 6.1.1
5+
SDK version supported: 7.1
66

7-
<b>The bindings sources along with build instructions are now available under [bindings](bindings)! </b>
7+
<b>This release only supports Ubuntu 22.04 for DeepStreamSDK 7.1 with Python 3.10 and [gst-python](3rdparty/gst-python/) 1.20.3! Ubuntu 20.04 for DeepStreamSDK 6.3 with Python 3.8 support is NOW DEPRECATED</b>
88

9-
<b>This release comes with Operating System upgrades (from Ubuntu 18.04 to Ubuntu 20.04) for DeepStreamSDK 6.1.1 support. This translates to upgrade in Python version to 3.8 and [gst-python](3rdparty/gst-python/) version has also been upgraded to 1.16.2 !</b>
10-
11-
Download the latest release package complete with bindings and sample applications from the [release section](../../releases).
9+
The bindings sources along with build instructions are available under [bindings](bindings)! PyDS 1.2.0 for DeepStream 7.1 uses an updated build system for PyPA to support pip 24.2, which deprecated setup.py command line. We include one [guide](bindings/BINDINGSGUIDE.md) for contributing to bindings and another [guide](bindings/CUSTOMUSERMETAGUIDE.md) for advanced use-cases such as writing bindings for custom data structures.
1210

1311
Please report any issues or bugs on the [DeepStream SDK Forums](https://devtalk.nvidia.com/default/board/209). This enables the DeepStream community to find help at a central location.
1412

13+
<b>NOTE:<b> numpy 2.x is not supported. If you have numpy 2.x installed, please downgrade by running
14+
```
15+
pip3 install --force-reinstall numpy==1.26.0
16+
```
17+
18+
<b>NOTE:<b> deepstream-segmask and deepstream-segmentation applications are not currently supported by DeepStream 7.1, due to removal of segmentation models.
19+
20+
<b>NOTE for DeepStream dockers:<b> If you installed PyDS by running the user_deepstream_python_apps_install.sh script, be sure you also run the <b>user_additional_install.sh script<b>.
21+
1522
- [DeepStream Python Apps](#deepstream-python-apps)
23+
- [Setup](#setup)
1624
- [Python Bindings](#python-bindings)
25+
- [Python Bindings Breaking API Change](#python-bindings-breaking-api-change)
1726
- [Sample Applications](#sample-applications)
1827

28+
## Setup
29+
Once you have DeepStreamSDK pre-requisites and DeepStreamSDK installed on the system, navigate to <DS_ROOT>/sources/ dir which is /opt/nvidia/deepstream/deepstream/sources/ and git clone deepstream_python_apps repo here.
30+
31+
The latest bindings can be installed from [release section](../../releases).
32+
You can also build the bindings from source using the instructions in the [bindings readme](bindings/README.md) if needed.
33+
1934
<a name="metadata_bindings"></a>
2035
## Python Bindings
2136

@@ -28,6 +43,9 @@ Python [bindings](bindings) are provided as part of this repository. This module
2843

2944
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.
3045

46+
### Python Bindings Breaking API Change
47+
The binding for function alloc_nvds_event_msg_meta() now expects a NvDsUserMeta pointer which the NvDsEventMsgMeta is associated with. Please refer to [deepstream-test4](apps/deepstream-test4) and [bindschema.cpp](bindings/src/bindschema.cpp) for reference.
48+
3149
<a name="sample_applications"></a>
3250
## Sample Applications
3351

@@ -41,22 +59,25 @@ To run the sample applications or write your own, please consult the [HOW-TO Gui
4159
</p>
4260

4361
We currently provide the following sample applications:
44-
* [deepstream-test1](apps/deepstream-test1) -- 4-class object detection pipeline
62+
* [deepstream-test1](apps/deepstream-test1) -- 4-class object detection pipeline, also demonstrates support for new nvstreammux
4563
* [deepstream-test2](apps/deepstream-test2) -- 4-class object detection, tracking and attribute classification pipeline
46-
* [deepstream-test3](apps/deepstream-test3) -- multi-stream pipeline performing 4-class object detection - now also supports triton inference server, no-display mode, file-loop and silent mode
64+
* [deepstream-test3](apps/deepstream-test3) -- multi-stream pipeline performing 4-class object detection, also supports triton inference server, no-display mode, file-loop and silent mode
4765
* [deepstream-test4](apps/deepstream-test4) -- msgbroker for sending analytics results to the cloud
4866
* [deepstream-imagedata-multistream](apps/deepstream-imagedata-multistream) -- multi-stream pipeline with access to image buffers
4967
* [deepstream-ssd-parser](apps/deepstream-ssd-parser) -- SSD model inference via Triton server with output parsing in Python
50-
* [deepstream-test1-usbcam](apps/deepstream-test1-usbcam) -- deepstream-test1 pipelien with USB camera input
51-
* [deepstream-test1-rtsp-out](apps/deepstream-test1-rtsp-out) -- deepstream-test1 pipeline with RTSP output
68+
* [deepstream-test1-usbcam](apps/deepstream-test1-usbcam) -- deepstream-test1 pipeline with USB camera input
69+
* [deepstream-test1-rtsp-out](apps/deepstream-test1-rtsp-out) -- deepstream-test1 pipeline with RTSP output, demonstrates adding software encoder option to support Jetson Orin Nano
5270
* [deepstream-opticalflow](apps/deepstream-opticalflow) -- optical flow and visualization pipeline with flow vectors returned in NumPy array
53-
* [deepstream-segmentation](apps/deepstream-segmentation) -- segmentation and visualization pipeline with segmentation mask returned in NumPy array
71+
* [deepstream-segmentation](apps/deepstream-segmentation) -- **NOT CURRENTLY SUPPORTED IN DS 7.1** segmentation and visualization pipeline with segmentation mask returned in NumPy array
5472
* [deepstream-nvdsanalytics](apps/deepstream-nvdsanalytics) -- multistream pipeline with analytics plugin
5573
* [runtime_source_add_delete](apps/runtime_source_add_delete) -- add/delete source streams at runtime
5674
* [deepstream-imagedata-multistream-redaction](apps/deepstream-imagedata-multistream-redaction) -- multi-stream pipeline with face detection and redaction
57-
* [deepstream-rtsp-in-rtsp-out](apps/deepstream-rtsp-in-rtsp-out) -- multi-stream pipeline with RTSP input/output
75+
* [deepstream-rtsp-in-rtsp-out](apps/deepstream-rtsp-in-rtsp-out) -- multi-stream pipeline with RTSP input/output - has command line option "--rtsp-ts" for configuring the RTSP source to attach the timestamp rather than the streammux
5876
* [deepstream-preprocess-test](apps/deepstream-preprocess-test) -- multi-stream pipeline using nvdspreprocess plugin with custom ROIs
59-
* <b>NEW</b> [deepstream-demux-multi-in-multi-out](apps/deepstream-demux-multi-in-multi-out) -- multi-stream pipeline using nvstreamdemux plugin to generated separate buffer outputs
77+
* [deepstream-demux-multi-in-multi-out](apps/deepstream-demux-multi-in-multi-out) -- multi-stream pipeline using nvstreamdemux plugin to generated separate buffer outputs
78+
* [deepstream-imagedata-multistream-cupy](apps/deepstream-imagedata-multistream-cupy) -- access imagedata buffer from GPU in a multistream source as CuPy array - x86 only
79+
* [deepstream-segmask](apps/deepstream-segmask) -- **NOT CURRENTLY SUPPORTED IN DS 7.1** access and interpret segmentation mask information from NvOSD_MaskParams
80+
* [deepstream-custom-binding-test](apps/deepstream-custom-binding-test) -- demonstrate usage of NvDsUserMeta for attaching custom data structure - see also the [Custom User Meta Guide](bindings/CUSTOMUSERMETAGUIDE.md)
6081

6182

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

0 commit comments

Comments
 (0)