diff --git a/.gitmodules b/.gitmodules index 585f2e0..b9ce656 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "3rdparty/pybind11"] path = 3rdparty/pybind11 url = https://github.com/pybind/pybind11.git -[submodule "3rdparty/gst-python"] - path = 3rdparty/gst-python - url = https://github.com/GStreamer/gst-python.git +[submodule "gstreamer"] + path = 3rdparty/gstreamer + url = https://github.com/GStreamer/gstreamer.git diff --git a/3rdparty/gst-python b/3rdparty/gst-python deleted file mode 160000 index 1a8f48a..0000000 --- a/3rdparty/gst-python +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1a8f48a6c2911b308231a3843f771a50775cbd2e diff --git a/FAQ.md b/FAQ.md index 2f1761d..6c6dc0e 100644 --- a/FAQ.md +++ b/FAQ.md @@ -1,6 +1,7 @@ # Frequently Asked Questions and Troubleshooting Guide - [Frequently Asked Questions and Troubleshooting Guide](#frequently-asked-questions-and-troubleshooting-guide) + - [App causes Jetson Orin Nano to freeze and reboot](#app-causes-jetson-orin-nano-to-freeze-and-reboot) - [Using new gst-nvstreammux](#using-new-gst-nvstreammux) - [Git clone fails due to Gstreamer repo access error](#git-clone-fails-due-to-gstreamer-repo-access-error) - [Application fails to work with mp4 stream](#application-fails-to-work-with-mp4-stream) @@ -13,6 +14,18 @@ - [Triton container problems with multi-GPU setup](#triton-container-problems-with-multi-gpu-setup) - [ModuleNotFoundError: No module named 'pyds'](#modulenotfounderror-no-module-named-pyds) + +### App causes Jetson Orin Nano to freeze and reboot +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): +```python +if codec == "H264": + encoder = Gst.ElementFactory.make("nvv4l2h264enc", "encoder") + if enc_type == 0: # HW encoder + encoder = Gst.ElementFactory.make("nvv4l2h264enc", "encoder") + else: # SW encoder + encoder = Gst.ElementFactory.make("x264enc", "encoder") +``` + ### Using new gst-nvstreammux 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: @@ -152,5 +165,5 @@ The pyds wheel installs the pyds.so library where all the pip packages are store Command to install the pyds wheel is: ```bash - $ pip3 install ./pyds-1.1.8-py3-none*.whl + $ pip3 install ./pyds-1.1.10-py3-none*.whl ``` \ No newline at end of file diff --git a/HOWTO.md b/HOWTO.md index b80a8ee..0362c86 100644 --- a/HOWTO.md +++ b/HOWTO.md @@ -15,10 +15,10 @@ This guide provides resources for DeepStream application development in Python. ## Prerequisites -* Ubuntu 20.04 -* [DeepStream SDK 6.3](https://developer.nvidia.com/deepstream-download) or later -* Python 3.8 -* [Gst Python](https://gstreamer.freedesktop.org/modules/gst-python.html) v1.16.2 +* Ubuntu 22.04 +* [DeepStream SDK 6.4](https://developer.nvidia.com/deepstream-download) or later +* Python 3.10 +* [Gst Python](https://gstreamer.freedesktop.org/modules/gst-python.html) v1.20.3 Gst python should be already installed on Jetson. If missing, install with the following steps: @@ -84,12 +84,12 @@ Memory for MetaData is shared by the Python and C/C++ code paths. For example, a #### Allocations -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. +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. Example: To allocate an NvDsEventMsgMeta instance, use this: ```python -msg_meta = pyds.alloc_nvds_event_msg_meta() # get reference to allocated instance without claiming memory ownership +msg_meta = pyds.alloc_nvds_event_msg_meta(user_event_meta) # get reference to allocated instance without claiming memory ownership ``` NOT this: ```python @@ -173,16 +173,21 @@ frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data) 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. -Callback functions are registered using these functions: +##### Deprecation Warning +Previously, Callback functions were registered using these functions: ```python pyds.set_user_copyfunc(NvDsUserMeta_instance, copy_function) pyds.set_user_releasefunc(NvDsUserMeta_instance, free_func) ``` -*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: +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) + +##### Deprecation Warning +*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: ```pyds.unset_callback_funcs()``` +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) -See the deepstream-test4 sample application for an example of callback registration and unregistration. +The deepstream-test4 sample application has been updated to show an example of removal of these callback registration and unregistration. Limitation: the bindings library currently only supports a single set of callback functions for each application. The last registered function will be used. diff --git a/README.md b/README.md index 958a438..f9d5a10 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ This repository contains Python bindings and sample applications for the [DeepStream SDK](https://developer.nvidia.com/deepstream-sdk). -SDK version supported: 6.3 +SDK version supported: 6.4 -The bindings sources along with build instructions are now available under [bindings](bindings)! We now include a [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. +This release only supports Ubuntu 22.04 for DeepStreamSDK 6.4 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 -This release only supports Ubuntu 20.04 for DeepStreamSDK 6.3 with Python 3.8 and [gst-python](3rdparty/gst-python/) 1.16.2! Ubuntu 18.04 support is now deprecrated. +The bindings sources along with build instructions are available under [bindings](bindings)! 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. Download the latest release package complete with bindings and sample applications from the [release section](../../releases). @@ -28,6 +28,9 @@ Python [bindings](bindings) are provided as part of this repository. This module 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. +### Python Bindings Breaking API Change +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. + ## Sample Applications @@ -41,20 +44,20 @@ To run the sample applications or write your own, please consult the [HOW-TO Gui

We currently provide the following sample applications: -* [deepstream-test1](apps/deepstream-test1) -- 4-class object detection pipeline - now also demonstrates support for new nvstreammux -* [deepstream-test2](apps/deepstream-test2) -- 4-class object detection, tracking and attribute classification pipeline -* [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 -* [deepstream-test4](apps/deepstream-test4) -- msgbroker for sending analytics results to the cloud +* [deepstream-test1](apps/deepstream-test1) -- 4-class object detection pipeline, also demonstrates support for new nvstreammux +* **UPDATED** [deepstream-test2](apps/deepstream-test2) -- 4-class object detection, tracking and attribute classification pipeline - now uses new names for tracker meta data types in DS 6.4 +* [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 +* **UPDATED** [deepstream-test4](apps/deepstream-test4) -- msgbroker for sending analytics results to the cloud - now supports MQTT protocol adaptor * [deepstream-imagedata-multistream](apps/deepstream-imagedata-multistream) -- multi-stream pipeline with access to image buffers * [deepstream-ssd-parser](apps/deepstream-ssd-parser) -- SSD model inference via Triton server with output parsing in Python * [deepstream-test1-usbcam](apps/deepstream-test1-usbcam) -- deepstream-test1 pipeline with USB camera input -* [deepstream-test1-rtsp-out](apps/deepstream-test1-rtsp-out) -- deepstream-test1 pipeline with RTSP output +* **UPDATED** [deepstream-test1-rtsp-out](apps/deepstream-test1-rtsp-out) -- deepstream-test1 pipeline with RTSP output - now demonstrates adding software encoder option to support Jetson Orin Nano * [deepstream-opticalflow](apps/deepstream-opticalflow) -- optical flow and visualization pipeline with flow vectors returned in NumPy array * [deepstream-segmentation](apps/deepstream-segmentation) -- segmentation and visualization pipeline with segmentation mask returned in NumPy array * [deepstream-nvdsanalytics](apps/deepstream-nvdsanalytics) -- multistream pipeline with analytics plugin * [runtime_source_add_delete](apps/runtime_source_add_delete) -- add/delete source streams at runtime * [deepstream-imagedata-multistream-redaction](apps/deepstream-imagedata-multistream-redaction) -- multi-stream pipeline with face detection and redaction -* UPDATED [deepstream-rtsp-in-rtsp-out](apps/deepstream-rtsp-in-rtsp-out) -- multi-stream pipeline with RTSP input/output -- now takes new command line argument "--rtsp-ts" for configuring the RTSP source to attach the timestamp rather than the streammux +* [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 * [deepstream-preprocess-test](apps/deepstream-preprocess-test) -- multi-stream pipeline using nvdspreprocess plugin with custom ROIs * [deepstream-demux-multi-in-multi-out](apps/deepstream-demux-multi-in-multi-out) -- multi-stream pipeline using nvstreamdemux plugin to generated separate buffer outputs * [deepstream-imagedata-multistream-cupy](apps/deepstream-imagedata-multistream-cupy) -- access imagedata buffer from GPU in a multistream source as CuPy array - x86 only diff --git a/apps/README b/apps/README index 0b6740f..3dcc0f6 100644 --- a/apps/README +++ b/apps/README @@ -19,9 +19,9 @@ DeepStream SDK Python Bindings ================================================================================ Setup pre-requisites: -- Ubuntu 20.04 -- NVIDIA DeepStream SDK 6.3 -- Python 3.8 +- Ubuntu 22.04 +- NVIDIA DeepStream SDK 6.4 +- Python 3.10 - Gst-python -------------------------------------------------------------------------------- @@ -36,13 +36,13 @@ Package Contents Installing Pre-requisites: -------------------------------------------------------------------------------- -DeepStream SDK 6.3 +DeepStream SDK 6.4 -------------------- Download and install from https://developer.nvidia.com/deepstream-download -Python 3.8 +Python 3.10 ---------- -Should be already installed with Ubuntu 20.04 +Should be already installed with Ubuntu 22.04 Gst-python ---------- @@ -54,7 +54,7 @@ $ sudo apt install python3-gi python3-dev python3-gst-1.0 -y -------------------------------------------------------------------------------- Running the samples -------------------------------------------------------------------------------- -The apps are configured to work from inside the DeepStream SDK 6.3 installation. +The apps are configured to work from inside the DeepStream SDK 6.4 installation. Clone the deepstream_python_apps repo under /sources: $ git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps diff --git a/apps/deepstream-custom-binding-test/README b/apps/deepstream-custom-binding-test/README index 0152b0d..7afdec7 100644 --- a/apps/deepstream-custom-binding-test/README +++ b/apps/deepstream-custom-binding-test/README @@ -16,8 +16,8 @@ ################################################################################ Prequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python To run the test app: diff --git a/apps/deepstream-demux-multi-in-multi-out/README b/apps/deepstream-demux-multi-in-multi-out/README index e76bcec..d7834c5 100644 --- a/apps/deepstream-demux-multi-in-multi-out/README +++ b/apps/deepstream-demux-multi-in-multi-out/README @@ -16,8 +16,8 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python To run: diff --git a/apps/deepstream-demux-multi-in-multi-out/deepstream_demux_multi_in_multi_out.py b/apps/deepstream-demux-multi-in-multi-out/deepstream_demux_multi_in_multi_out.py index dbbf67e..85ed38c 100644 --- a/apps/deepstream-demux-multi-in-multi-out/deepstream_demux_multi_in_multi_out.py +++ b/apps/deepstream-demux-multi-in-multi-out/deepstream_demux_multi_in_multi_out.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -50,7 +50,7 @@ PGIE_CLASS_ID_ROADSIGN = 3 MUXER_OUTPUT_WIDTH = 540 MUXER_OUTPUT_HEIGHT = 540 # 1080 -MUXER_BATCH_TIMEOUT_USEC = 4000000 +MUXER_BATCH_TIMEOUT_USEC = 33000 TILED_OUTPUT_WIDTH = 640 # 1280 TILED_OUTPUT_HEIGHT = 360 # 720 GST_CAPS_FEATURES_NVMM = "memory:NVMM" @@ -321,7 +321,7 @@ def main(args, requested_pgie=None, config=None, disable_probe=False): streammux.set_property("width", 960) streammux.set_property("height", 540) streammux.set_property("batch-size", number_sources) - streammux.set_property("batched-push-timeout", 4000000) + streammux.set_property("batched-push-timeout", MUXER_BATCH_TIMEOUT_USEC) pgie.set_property("config-file-path", "ds_demux_pgie_config.txt") pgie_batch_size = pgie.get_property("batch-size") if pgie_batch_size != number_sources: diff --git a/apps/deepstream-demux-multi-in-multi-out/ds_demux_pgie_config.txt b/apps/deepstream-demux-multi-in-multi-out/ds_demux_pgie_config.txt index 48ea51a..a0e4e0f 100644 --- a/apps/deepstream-demux-multi-in-multi-out/ds_demux_pgie_config.txt +++ b/apps/deepstream-demux-multi-in-multi-out/ds_demux_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +26,7 @@ # # Optional properties for detectors: # cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0) -# custom-lib-path +# custom-lib-path, # parse-bbox-func-name # # Mandatory properties for classifiers: @@ -54,24 +54,30 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 +batch-size=30 process-mode=1 model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd +#scaling-filter=0 +#scaling-compute-hw=0 cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -topk=20 -nms-iou-threshold=0.5 +eps=0.2 +group-threshold=1 diff --git a/apps/deepstream-imagedata-multistream-cupy/README b/apps/deepstream-imagedata-multistream-cupy/README index 8c4f4bd..8b9d06d 100644 --- a/apps/deepstream-imagedata-multistream-cupy/README +++ b/apps/deepstream-imagedata-multistream-cupy/README @@ -16,8 +16,8 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python - NumPy package - OpenCV package diff --git a/apps/deepstream-imagedata-multistream-cupy/deepstream_imagedata-multistream_cupy.py b/apps/deepstream-imagedata-multistream-cupy/deepstream_imagedata-multistream_cupy.py index 2122681..4ce0d5d 100644 --- a/apps/deepstream-imagedata-multistream-cupy/deepstream_imagedata-multistream_cupy.py +++ b/apps/deepstream-imagedata-multistream-cupy/deepstream_imagedata-multistream_cupy.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,7 +45,7 @@ PGIE_CLASS_ID_ROADSIGN = 3 MUXER_OUTPUT_WIDTH = 1920 MUXER_OUTPUT_HEIGHT = 1080 -MUXER_BATCH_TIMEOUT_USEC = 4000000 +MUXER_BATCH_TIMEOUT_USEC = 33000 TILED_OUTPUT_WIDTH = 1920 TILED_OUTPUT_HEIGHT = 1080 GST_CAPS_FEATURES_NVMM = "memory:NVMM" @@ -285,7 +285,7 @@ def main(args): streammux.set_property('width', 1920) streammux.set_property('height', 1080) streammux.set_property('batch-size', number_sources) - streammux.set_property('batched-push-timeout', 4000000) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) pgie.set_property('config-file-path', "dstest_imagedata_cupy_config.txt") pgie_batch_size = pgie.get_property("batch-size") if (pgie_batch_size != number_sources): diff --git a/apps/deepstream-imagedata-multistream-cupy/dstest_imagedata_cupy_config.txt b/apps/deepstream-imagedata-multistream-cupy/dstest_imagedata_cupy_config.txt index 1d698ba..a0e4e0f 100644 --- a/apps/deepstream-imagedata-multistream-cupy/dstest_imagedata_cupy_config.txt +++ b/apps/deepstream-imagedata-multistream-cupy/dstest_imagedata_cupy_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +26,7 @@ # # Optional properties for detectors: # cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0) -# custom-lib-path +# custom-lib-path, # parse-bbox-func-name # # Mandatory properties for classifiers: @@ -54,52 +54,30 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 +batch-size=30 process-mode=1 model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid -## 0=Group Rectangles, 1=DBSCAN, 2=NMS, 3= DBSCAN+NMS Hybrid, 4 = None(No clustering) -cluster-mode=1 +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd +#scaling-filter=0 +#scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.7 -minBoxes=1 - -#Use the config params below for dbscan clustering mode -[class-attrs-all] -detected-min-w=4 -detected-min-h=4 -minBoxes=3 - -## Per class configurations -[class-attrs-0] -pre-cluster-threshold=0.05 -eps=0.7 -dbscan-min-score=0.95 - -[class-attrs-1] -pre-cluster-threshold=0.05 -eps=0.7 -dbscan-min-score=0.5 - -[class-attrs-2] -pre-cluster-threshold=0.1 -eps=0.6 -dbscan-min-score=0.95 - -[class-attrs-3] -pre-cluster-threshold=0.05 -eps=0.7 -dbscan-min-score=0.5 +eps=0.2 +group-threshold=1 diff --git a/apps/deepstream-imagedata-multistream-redaction/README b/apps/deepstream-imagedata-multistream-redaction/README index 813062f..d26cf1c 100755 --- a/apps/deepstream-imagedata-multistream-redaction/README +++ b/apps/deepstream-imagedata-multistream-redaction/README @@ -16,8 +16,8 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python - NumPy package - OpenCV package @@ -40,7 +40,7 @@ Yet, we need to install the introspection typelib package: Download Peoplenet model: Please follow instructions from the README.md located at : /opt/nvidia/deepstream/deepstream/samples/configs/tao_pretrained_models/README.md - to download latest supported peoplenet model (V2.6 for this release) + to download latest supported peoplenet model To run: $ python3 deepstream_imagedata-multistream_redaction.py -i [uri2] ... [uriN] -c {H264,H265} -b BITRATE diff --git a/apps/deepstream-imagedata-multistream-redaction/config_infer_primary_peoplenet.txt b/apps/deepstream-imagedata-multistream-redaction/config_infer_primary_peoplenet.txt index 480dad1..5839911 100644 --- a/apps/deepstream-imagedata-multistream-redaction/config_infer_primary_peoplenet.txt +++ b/apps/deepstream-imagedata-multistream-redaction/config_infer_primary_peoplenet.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,11 +18,11 @@ [property] gpu-id=0 net-scale-factor=0.0039215697906911373 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/tao_pretrained_models/peopleNet/V2.6/resnet34_peoplenet_int8.etlt +#tlt-model-key=tlt_encode +onnx-file=../../../../samples/models/tao_pretrained_models/peopleNet/resnet34_peoplenet_int8.onnx labelfile-path=../../../../samples/configs/tao_pretrained_models/labels_peoplenet.txt -model-engine-file=../../../../samples/models/tao_pretrained_models/peopleNet/V2.6/resnet34_peoplenet_int8.etlt_b1_gpu0_int8.engine -int8-calib-file=../../../../samples/models/tao_pretrained_models/peopleNet/V2.6/resnet34_peoplenet_int8.txt +model-engine-file=../../../../samples/models/tao_pretrained_models/peopleNet/resnet34_peoplenet_int8.onnx_b1_gpu0_int8.engine +int8-calib-file=../../../../samples/models/tao_pretrained_models/peopleNet/resnet34_peoplenet_int8.txt input-dims=3;544;960;0 uff-input-blob-name=input_1 batch-size=1 diff --git a/apps/deepstream-imagedata-multistream-redaction/deepstream_imagedata-multistream_redaction.py b/apps/deepstream-imagedata-multistream-redaction/deepstream_imagedata-multistream_redaction.py index c4397d6..65dc2ba 100644 --- a/apps/deepstream-imagedata-multistream-redaction/deepstream_imagedata-multistream_redaction.py +++ b/apps/deepstream-imagedata-multistream-redaction/deepstream_imagedata-multistream_redaction.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -56,7 +56,7 @@ MUXER_OUTPUT_WIDTH = 720 MUXER_OUTPUT_HEIGHT = 576 -MUXER_BATCH_TIMEOUT_USEC = 400000 +MUXER_BATCH_TIMEOUT_USEC = 33000 TILED_OUTPUT_WIDTH = 720 TILED_OUTPUT_HEIGHT = 576 GST_CAPS_FEATURES_NVMM = "memory:NVMM" @@ -385,7 +385,7 @@ def main(uri_inputs,codec,bitrate ): streammux.set_property('width', 1920) streammux.set_property('height', 1080) streammux.set_property('batch-size', number_sources) - streammux.set_property('batched-push-timeout', 4000000) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) pgie.set_property('config-file-path', "config_infer_primary_peoplenet.txt") pgie_batch_size = pgie.get_property("batch-size") if (pgie_batch_size != number_sources): diff --git a/apps/deepstream-imagedata-multistream/README b/apps/deepstream-imagedata-multistream/README index 2b16020..0ce24d7 100755 --- a/apps/deepstream-imagedata-multistream/README +++ b/apps/deepstream-imagedata-multistream/README @@ -16,8 +16,8 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python - NumPy package - OpenCV package diff --git a/apps/deepstream-imagedata-multistream/deepstream_imagedata-multistream.py b/apps/deepstream-imagedata-multistream/deepstream_imagedata-multistream.py index b1a2e93..489e2da 100755 --- a/apps/deepstream-imagedata-multistream/deepstream_imagedata-multistream.py +++ b/apps/deepstream-imagedata-multistream/deepstream_imagedata-multistream.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,7 +55,7 @@ PGIE_CLASS_ID_ROADSIGN = 3 MUXER_OUTPUT_WIDTH = 1920 MUXER_OUTPUT_HEIGHT = 1080 -MUXER_BATCH_TIMEOUT_USEC = 4000000 +MUXER_BATCH_TIMEOUT_USEC = 33000 TILED_OUTPUT_WIDTH = 1920 TILED_OUTPUT_HEIGHT = 1080 GST_CAPS_FEATURES_NVMM = "memory:NVMM" @@ -361,7 +361,7 @@ def main(args): streammux.set_property('width', 1920) streammux.set_property('height', 1080) streammux.set_property('batch-size', number_sources) - streammux.set_property('batched-push-timeout', 4000000) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) pgie.set_property('config-file-path', "dstest_imagedata_config.txt") pgie_batch_size = pgie.get_property("batch-size") if (pgie_batch_size != number_sources): diff --git a/apps/deepstream-imagedata-multistream/dstest_imagedata_config.txt b/apps/deepstream-imagedata-multistream/dstest_imagedata_config.txt index 4687923..a0e4e0f 100755 --- a/apps/deepstream-imagedata-multistream/dstest_imagedata_config.txt +++ b/apps/deepstream-imagedata-multistream/dstest_imagedata_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +26,7 @@ # # Optional properties for detectors: # cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0) -# custom-lib-path +# custom-lib-path, # parse-bbox-func-name # # Mandatory properties for classifiers: @@ -54,52 +54,30 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 +batch-size=30 process-mode=1 model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid -## 0=Group Rectangles, 1=DBSCAN, 2=NMS, 3= DBSCAN+NMS Hybrid, 4 = None(No clustering) -cluster-mode=1 +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd +#scaling-filter=0 +#scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.7 -minBoxes=1 - -#Use the config params below for dbscan clustering mode -[class-attrs-all] -detected-min-w=4 -detected-min-h=4 -minBoxes=3 - -## Per class configurations -[class-attrs-0] -pre-cluster-threshold=0.05 -eps=0.7 -dbscan-min-score=0.95 - -[class-attrs-1] -pre-cluster-threshold=0.05 -eps=0.7 -dbscan-min-score=0.5 - -[class-attrs-2] -pre-cluster-threshold=0.1 -eps=0.6 -dbscan-min-score=0.95 - -[class-attrs-3] -pre-cluster-threshold=0.05 -eps=0.7 -dbscan-min-score=0.5 +eps=0.2 +group-threshold=1 diff --git a/apps/deepstream-nvdsanalytics/README b/apps/deepstream-nvdsanalytics/README index 489f967..9757907 100755 --- a/apps/deepstream-nvdsanalytics/README +++ b/apps/deepstream-nvdsanalytics/README @@ -16,8 +16,8 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python To run: diff --git a/apps/deepstream-nvdsanalytics/deepstream_nvdsanalytics.py b/apps/deepstream-nvdsanalytics/deepstream_nvdsanalytics.py index 208ddf3..0b4cdef 100755 --- a/apps/deepstream-nvdsanalytics/deepstream_nvdsanalytics.py +++ b/apps/deepstream-nvdsanalytics/deepstream_nvdsanalytics.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -43,7 +43,7 @@ PGIE_CLASS_ID_ROADSIGN = 3 MUXER_OUTPUT_WIDTH=1920 MUXER_OUTPUT_HEIGHT=1080 -MUXER_BATCH_TIMEOUT_USEC=4000000 +MUXER_BATCH_TIMEOUT_USEC = 33000 TILED_OUTPUT_WIDTH=1280 TILED_OUTPUT_HEIGHT=720 GST_CAPS_FEATURES_NVMM="memory:NVMM" @@ -329,7 +329,7 @@ def main(args): streammux.set_property('width', 1920) streammux.set_property('height', 1080) streammux.set_property('batch-size', number_sources) - streammux.set_property('batched-push-timeout', 4000000) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) pgie.set_property('config-file-path', "dsnvanalytics_pgie_config.txt") pgie_batch_size=pgie.get_property("batch-size") if(pgie_batch_size != number_sources): diff --git a/apps/deepstream-nvdsanalytics/dsnvanalytics_pgie_config.txt b/apps/deepstream-nvdsanalytics/dsnvanalytics_pgie_config.txt index 0246ba5..a0e4e0f 100644 --- a/apps/deepstream-nvdsanalytics/dsnvanalytics_pgie_config.txt +++ b/apps/deepstream-nvdsanalytics/dsnvanalytics_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +26,7 @@ # # Optional properties for detectors: # cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0) -# custom-lib-path +# custom-lib-path, # parse-bbox-func-name # # Mandatory properties for classifiers: @@ -54,21 +54,28 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 +batch-size=30 process-mode=1 model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd +#scaling-filter=0 +#scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 diff --git a/apps/deepstream-nvdsanalytics/dsnvanalytics_tracker_config.txt b/apps/deepstream-nvdsanalytics/dsnvanalytics_tracker_config.txt index b648da1..e085028 100644 --- a/apps/deepstream-nvdsanalytics/dsnvanalytics_tracker_config.txt +++ b/apps/deepstream-nvdsanalytics/dsnvanalytics_tracker_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/apps/deepstream-opticalflow/README b/apps/deepstream-opticalflow/README index 426138b..4b35bb4 100755 --- a/apps/deepstream-opticalflow/README +++ b/apps/deepstream-opticalflow/README @@ -16,8 +16,8 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python - NumPy package - OpenCV package diff --git a/apps/deepstream-opticalflow/deepstream-opticalflow.py b/apps/deepstream-opticalflow/deepstream-opticalflow.py index 1a67dbf..1cbae72 100755 --- a/apps/deepstream-opticalflow/deepstream-opticalflow.py +++ b/apps/deepstream-opticalflow/deepstream-opticalflow.py @@ -1,5 +1,7 @@ +#!/usr/bin/env python3 + ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,33 +19,35 @@ """ Deepstream optical flow application """ -import math -import os -from os import path import sys - sys.path.append('../') -import cv2 -import numpy as np - +from pathlib import Path import gi - gi.require_version('Gst', '1.0') from gi.repository import GLib, Gst - +import sys +import math from common.is_aarch_64 import is_aarch64 from common.bus_call import bus_call +import os +from os import path + +import cv2 +import numpy as np + import pyds + MAX_DISPLAY_LEN = 64 MUXER_OUTPUT_WIDTH = 1280 MUXER_OUTPUT_HEIGHT = 720 -MUXER_BATCH_TIMEOUT_USEC = 3400000 +MUXER_BATCH_TIMEOUT_USEC = 33000 TILED_OUTPUT_WIDTH = 1280 TILED_OUTPUT_HEIGHT = 720 GST_CAPS_FEATURES_NVMM = "memory:NVMM" + def visualize_optical_flowvectors(flow): """ Converts the flow u, v vectors into visualization by mapping them into @@ -114,8 +118,8 @@ def ofvisual_queue_src_pad_buffer_probe(pad, info, u_data): print("Frame Number=", frame_number) if got_visual: - cv2.imwrite(folder_name + "/stream_" + str(frame_meta.pad_index) - + "/frame_" + str(frame_number) + ".jpg", flow_visual) + img_path = "{}/stream_{}/frame_{}.jpg".format(folder_name, frame_meta.pad_index, frame_number) + cv2.imwrite(img_path, flow_visual) try: l_frame = l_frame.next except StopIteration: @@ -124,76 +128,80 @@ def ofvisual_queue_src_pad_buffer_probe(pad, info, u_data): return Gst.PadProbeReturn.OK -def cb_newpad(decodebin, decoder_src_pad, data): + +def cb_newpad(decodebin, decoder_src_pad,data): print("In cb_newpad\n") - caps = decoder_src_pad.get_current_caps() - gststruct = caps.get_structure(0) - gstname = gststruct.get_name() - source_bin = data - features = caps.get_features(0) + caps=decoder_src_pad.get_current_caps() + gststruct=caps.get_structure(0) + gstname=gststruct.get_name() + source_bin=data + features=caps.get_features(0) # Need to check if the pad created by the decodebin is for video and not # audio. - print("gstname=", gstname) - if gstname.find("video") != -1: + print("gstname=",gstname) + if(gstname.find("video")!=-1): # Link the decodebin pad only if decodebin has picked nvidia # decoder plugin nvdec_*. We do this by checking if the pad caps contain # NVMM memory features. - print("features=", features) + print("features=",features) if features.contains("memory:NVMM"): # Get the source bin ghost pad - bin_ghost_pad = source_bin.get_static_pad("src") + bin_ghost_pad=source_bin.get_static_pad("src") if not bin_ghost_pad.set_target(decoder_src_pad): sys.stderr.write("Failed to link decoder src pad to source bin ghost pad\n") else: sys.stderr.write(" Error: Decodebin did not pick nvidia decoder plugin.\n") - -def decodebin_child_added(child_proxy, Object, name, user_data): +def decodebin_child_added(child_proxy,Object,name,user_data): print("Decodebin child added:", name, "\n") - if name.find("decodebin") != -1: - Object.connect("child-added", decodebin_child_added, user_data) + if(name.find("decodebin") != -1): + Object.connect("child-added",decodebin_child_added,user_data) + if "source" in name: + source_element = child_proxy.get_by_name("source") + if source_element.find_property('drop-on-latency') != None: + Object.set_property("drop-on-latency", True) -def create_source_bin(index, uri): + + +def create_source_bin(index,uri): print("Creating source bin") # Create a source GstBin to abstract this bin's content from the rest of the # pipeline - bin_name = "source-bin-%02d" % index + bin_name="source-bin-%02d" %index print(bin_name) - nbin = Gst.Bin.new(bin_name) + nbin=Gst.Bin.new(bin_name) if not nbin: sys.stderr.write(" Unable to create source bin \n") # Source element for reading from the uri. # We will use decodebin and let it figure out the container format of the # stream and the codec and plug the appropriate demux and decode plugins. - uri_decode_bin = Gst.ElementFactory.make("uridecodebin", "uri-decode-bin") + uri_decode_bin=Gst.ElementFactory.make("uridecodebin", "uri-decode-bin") if not uri_decode_bin: sys.stderr.write(" Unable to create uri decode bin \n") # We set the input uri to the source element - uri_decode_bin.set_property("uri", uri) + uri_decode_bin.set_property("uri",uri) # Connect to the "pad-added" signal of the decodebin which generates a # callback once a new pad for raw data has beed created by the decodebin - uri_decode_bin.connect("pad-added", cb_newpad, nbin) - uri_decode_bin.connect("child-added", decodebin_child_added, nbin) + uri_decode_bin.connect("pad-added",cb_newpad,nbin) + uri_decode_bin.connect("child-added",decodebin_child_added,nbin) # We need to create a ghost pad for the source bin which will act as a proxy # for the video decoder src pad. The ghost pad will not have a target right # now. Once the decode bin creates the video decoder and generates the # cb_newpad callback, we will set the ghost pad target to the video decoder # src pad. - Gst.Bin.add(nbin, uri_decode_bin) - bin_pad = nbin.add_pad(Gst.GhostPad.new_no_target("src", Gst.PadDirection.SRC)) + Gst.Bin.add(nbin,uri_decode_bin) + bin_pad=nbin.add_pad(Gst.GhostPad.new_no_target("src",Gst.PadDirection.SRC)) if not bin_pad: sys.stderr.write(" Failed to add ghost pad in source bin \n") return None return nbin - def main(args): - # Check input arguments if len(args) < 2: sys.stderr.write("usage: %s [uri2] ... [uriN] \n" % args[0]) sys.exit(1) @@ -209,11 +217,11 @@ def main(args): os.mkdir(folder_name) # Standard GStreamer initialization Gst.init(None) - # Create gstreamer elements */ # Create Pipeline element that will form a connection of other elements print("Creating Pipeline \n ") pipeline = Gst.Pipeline() + is_live = False if not pipeline: sys.stderr.write(" Unable to create Pipeline \n") @@ -226,27 +234,43 @@ def main(args): pipeline.add(streammux) for i in range(number_sources): - print("Creating source_bin ", i, " \n ") - uri_name = args[i + 1] os.mkdir(folder_name + "/stream_" + str(i)) - source_bin = create_source_bin(i, uri_name) + print("Creating source_bin ",i," \n ") + uri_name=args[i + 1] + if uri_name.find("rtsp://") == 0 : + is_live = True + source_bin=create_source_bin(i, uri_name) if not source_bin: sys.stderr.write("Unable to create source bin \n") pipeline.add(source_bin) - padname = "sink_%u" % i - sinkpad = streammux.get_request_pad(padname) + padname="sink_%u" %i + sinkpad= streammux.get_request_pad(padname) if not sinkpad: sys.stderr.write("Unable to create sink pad bin \n") - srcpad = source_bin.get_static_pad("src") + srcpad=source_bin.get_static_pad("src") if not srcpad: sys.stderr.write("Unable to create src pad bin \n") srcpad.link(sinkpad) - + queue1=Gst.ElementFactory.make("queue","queue1") + queue2=Gst.ElementFactory.make("queue","queue2") + queue3=Gst.ElementFactory.make("queue","queue3") + queue4=Gst.ElementFactory.make("queue","queue4") + queue5=Gst.ElementFactory.make("queue","queue5") + pipeline.add(queue1) + pipeline.add(queue2) + pipeline.add(queue3) + pipeline.add(queue4) + pipeline.add(queue5) + print("Creating tiler \n ") - tiler = Gst.ElementFactory.make("nvmultistreamtiler", "nvtiler") + tiler=Gst.ElementFactory.make("nvmultistreamtiler", "nvtiler") if not tiler: sys.stderr.write(" Unable to create tiler \n") - print("Creating nv optical flow element \n") + print("Creating nvvidconv \n ") + nvvidconv = Gst.ElementFactory.make("nvvideoconvert", "convertor") + if not nvvidconv: + sys.stderr.write(" Unable to create nvvidconv \n") + nvof = Gst.ElementFactory.make("nvof", "nvopticalflow") if not nvof: sys.stderr.write("Unable to create optical flow \n") @@ -271,10 +295,12 @@ def main(args): nvosd = Gst.ElementFactory.make("nvdsosd", "onscreendisplay") if not nvosd: sys.stderr.write(" Unable to create nvosd \n") + print("Creating converter 2\n") nvvidconv2 = Gst.ElementFactory.make("nvvideoconvert", "convertor2") if not nvvidconv2: sys.stderr.write(" Unable to create nvvidconv2 \n") + print("Creating capsfilter \n") capsfilter = Gst.ElementFactory.make("capsfilter", "capsfilter") if not capsfilter: @@ -300,15 +326,20 @@ def main(args): sys.stderr.write(" Unable to create file sink \n") sink.set_property("location", "./out.mp4") sink.set_property("sync", 0) - streammux.set_property('width', 1280) - streammux.set_property('height', 720) + + if is_live: + print("At least one of the sources is live") + streammux.set_property('live-source', 1) + + streammux.set_property('width', 1920) + streammux.set_property('height', 1080) streammux.set_property('batch-size', number_sources) - streammux.set_property('batched-push-timeout', 33333) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) streammux.set_property('sync-inputs', 1) - tiler_rows = int(math.sqrt(number_sources)) - tiler_columns = int(math.ceil((1.0 * number_sources) / tiler_rows)) - tiler.set_property("rows", tiler_rows) - tiler.set_property("columns", tiler_columns) + tiler_rows=int(math.sqrt(number_sources)) + tiler_columns=int(math.ceil((1.0*number_sources)/tiler_rows)) + tiler.set_property("rows",tiler_rows) + tiler.set_property("columns",tiler_columns) tiler.set_property("width", TILED_OUTPUT_WIDTH) tiler.set_property("height", TILED_OUTPUT_HEIGHT) @@ -318,8 +349,8 @@ def main(args): pipeline.add(nvofvisual) pipeline.add(ofvisual_queue) pipeline.add(tiler) + pipeline.add(nvvidconv) pipeline.add(nvosd) - pipeline.add(queue) pipeline.add(nvvidconv2) pipeline.add(capsfilter) pipeline.add(encoder) @@ -328,25 +359,29 @@ def main(args): pipeline.add(sink) print("Linking elements in the Pipeline \n") - streammux.link(nvof) + streammux.link(queue1) + queue1.link(nvof) nvof.link(of_queue) of_queue.link(nvofvisual) nvofvisual.link(ofvisual_queue) ofvisual_queue.link(tiler) - tiler.link(nvosd) - nvosd.link(queue) - queue.link(nvvidconv2) + tiler.link(queue3) + queue3.link(nvvidconv) + nvvidconv.link(queue4) + queue4.link(nvosd) + nvosd.link(queue5) + queue5.link(nvvidconv2) nvvidconv2.link(capsfilter) capsfilter.link(encoder) encoder.link(codeparser) codeparser.link(container) - container.link(sink) + container.link(sink) # create an event loop and feed gstreamer bus mesages to it loop = GLib.MainLoop() bus = pipeline.get_bus() bus.add_signal_watch() - bus.connect("message", bus_call, loop) + bus.connect ("message", bus_call, loop) ofvisual_queue_src_pad = ofvisual_queue.get_static_pad("src") if not ofvisual_queue_src_pad: sys.stderr.write(" Unable to get src pad \n") @@ -357,9 +392,8 @@ def main(args): # List the sources print("Now playing...") - for i, source in enumerate(args[:-1]): - if i != 0: - print(i, ": ", source) + for i, source in enumerate(args): + print(i, ": ", source) print("Starting pipeline \n") # start play back and listed to events @@ -372,6 +406,6 @@ def main(args): print("Exiting app\n") pipeline.set_state(Gst.State.NULL) - if __name__ == '__main__': sys.exit(main(sys.argv)) + diff --git a/apps/deepstream-preprocess-test/README b/apps/deepstream-preprocess-test/README index 069403a..60de131 100644 --- a/apps/deepstream-preprocess-test/README +++ b/apps/deepstream-preprocess-test/README @@ -16,8 +16,8 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python - GstRtspServer diff --git a/apps/deepstream-preprocess-test/config_preprocess.txt b/apps/deepstream-preprocess-test/config_preprocess.txt index 844e580..127f5ed 100644 --- a/apps/deepstream-preprocess-test/config_preprocess.txt +++ b/apps/deepstream-preprocess-test/config_preprocess.txt @@ -29,12 +29,12 @@ maintain-aspect-ratio=1 # if enabled pad symmetrically with maintain-aspect-ratio enabled symmetric-padding=1 # processing width/height at which image scaled -processing-width=640 -processing-height=368 +processing-width=960 +processing-height=544 scaling-buf-pool-size=6 tensor-buf-pool-size=6 # tensor shape based on network-input-order -network-input-shape=12;3;368;640 +network-input-shape=8;3;544;960 # 0=RGB, 1=BGR, 2=GRAY network-color-format=0 diff --git a/apps/deepstream-preprocess-test/deepstream_preprocess_test.py b/apps/deepstream-preprocess-test/deepstream_preprocess_test.py index e06e4cd..3b267ce 100644 --- a/apps/deepstream-preprocess-test/deepstream_preprocess_test.py +++ b/apps/deepstream-preprocess-test/deepstream_preprocess_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,7 +47,7 @@ PGIE_CLASS_ID_ROADSIGN = 3 MUXER_OUTPUT_WIDTH = 1920 MUXER_OUTPUT_HEIGHT = 1080 -MUXER_BATCH_TIMEOUT_USEC = 4000000 +MUXER_BATCH_TIMEOUT_USEC = 33000 TILED_OUTPUT_WIDTH = 1280 TILED_OUTPUT_HEIGHT = 720 GST_CAPS_FEATURES_NVMM = "memory:NVMM" @@ -329,7 +329,7 @@ def main(args): streammux.set_property("width", 1920) streammux.set_property("height", 1080) streammux.set_property("batch-size", 1) - streammux.set_property("batched-push-timeout", 4000000) + streammux.set_property("batched-push-timeout", MUXER_BATCH_TIMEOUT_USEC) preprocess.set_property("config-file", "config_preprocess.txt") pgie.set_property("config-file-path", "dstest1_pgie_config.txt") diff --git a/apps/deepstream-preprocess-test/dstest1_pgie_config.txt b/apps/deepstream-preprocess-test/dstest1_pgie_config.txt index 930dbfd..a1d9f03 100644 --- a/apps/deepstream-preprocess-test/dstest1_pgie_config.txt +++ b/apps/deepstream-preprocess-test/dstest1_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,21 +54,28 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 batch-size=1 +process-mode=1 +model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 diff --git a/apps/deepstream-rtsp-in-rtsp-out/README b/apps/deepstream-rtsp-in-rtsp-out/README index 27f9039..d57167c 100755 --- a/apps/deepstream-rtsp-in-rtsp-out/README +++ b/apps/deepstream-rtsp-in-rtsp-out/README @@ -16,8 +16,8 @@ ################################################################################ Prequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python - GstRtspServer diff --git a/apps/deepstream-rtsp-in-rtsp-out/deepstream_test1_rtsp_in_rtsp_out.py b/apps/deepstream-rtsp-in-rtsp-out/deepstream_test1_rtsp_in_rtsp_out.py index d8af91a..022784e 100755 --- a/apps/deepstream-rtsp-in-rtsp-out/deepstream_test1_rtsp_in_rtsp_out.py +++ b/apps/deepstream-rtsp-in-rtsp-out/deepstream_test1_rtsp_in_rtsp_out.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,7 +41,7 @@ PGIE_CLASS_ID_ROADSIGN = 3 MUXER_OUTPUT_WIDTH = 1920 MUXER_OUTPUT_HEIGHT = 1080 -MUXER_BATCH_TIMEOUT_USEC = 4000000 +MUXER_BATCH_TIMEOUT_USEC = 33000 TILED_OUTPUT_WIDTH = 1280 TILED_OUTPUT_HEIGHT = 720 GST_CAPS_FEATURES_NVMM = "memory:NVMM" @@ -281,7 +281,7 @@ def main(args): streammux.set_property("width", 1920) streammux.set_property("height", 1080) streammux.set_property("batch-size", number_sources) - streammux.set_property("batched-push-timeout", 4000000) + streammux.set_property("batched-push-timeout", MUXER_BATCH_TIMEOUT_USEC) if ts_from_rtsp: streammux.set_property("attach-sys-ts", 0) diff --git a/apps/deepstream-rtsp-in-rtsp-out/dstest1_pgie_config.txt b/apps/deepstream-rtsp-in-rtsp-out/dstest1_pgie_config.txt index aebe5ca..a0e4e0f 100755 --- a/apps/deepstream-rtsp-in-rtsp-out/dstest1_pgie_config.txt +++ b/apps/deepstream-rtsp-in-rtsp-out/dstest1_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,21 +54,28 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 +batch-size=30 +process-mode=1 +model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 diff --git a/apps/deepstream-segmask/README b/apps/deepstream-segmask/README index 3df42c5..4c13d08 100644 --- a/apps/deepstream-segmask/README +++ b/apps/deepstream-segmask/README @@ -16,7 +16,8 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 6.3 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python - NumPy package - OpenCV package diff --git a/apps/deepstream-segmask/deepstream_segmask.py b/apps/deepstream-segmask/deepstream_segmask.py index fc9c684..d719e63 100644 --- a/apps/deepstream-segmask/deepstream_segmask.py +++ b/apps/deepstream-segmask/deepstream_segmask.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,7 +47,7 @@ MAX_DISPLAY_LEN = 64 MUXER_OUTPUT_WIDTH = 1920 MUXER_OUTPUT_HEIGHT = 1080 -MUXER_BATCH_TIMEOUT_USEC = 4000000 +MUXER_BATCH_TIMEOUT_USEC = 33000 TILED_OUTPUT_WIDTH = 1920 TILED_OUTPUT_HEIGHT = 1080 GST_CAPS_FEATURES_NVMM = "memory:NVMM" @@ -319,7 +319,7 @@ def main(stream_paths, output_folder): streammux.set_property('width', 1920) streammux.set_property('height', 1080) streammux.set_property('batch-size', number_sources) - streammux.set_property('batched-push-timeout', 4000000) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) pgie.set_property('config-file-path', "dstest_segmask_config.txt") pgie_batch_size = pgie.get_property("batch-size") if (pgie_batch_size != number_sources): diff --git a/apps/deepstream-segmask/dstest_segmask_config.txt b/apps/deepstream-segmask/dstest_segmask_config.txt index 3331c1f..fd0fb5e 100644 --- a/apps/deepstream-segmask/dstest_segmask_config.txt +++ b/apps/deepstream-segmask/dstest_segmask_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved. +# Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), diff --git a/apps/deepstream-segmentation/README b/apps/deepstream-segmentation/README index 5f06d23..0123d9a 100644 --- a/apps/deepstream-segmentation/README +++ b/apps/deepstream-segmentation/README @@ -16,8 +16,8 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python - NumPy package - OpenCV package diff --git a/apps/deepstream-segmentation/deepstream_segmentation.py b/apps/deepstream-segmentation/deepstream_segmentation.py index 19e1366..af46fb6 100755 --- a/apps/deepstream-segmentation/deepstream_segmentation.py +++ b/apps/deepstream-segmentation/deepstream_segmentation.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,7 +36,7 @@ MAX_DISPLAY_LEN = 64 MUXER_OUTPUT_WIDTH = 1920 MUXER_OUTPUT_HEIGHT = 1080 -MUXER_BATCH_TIMEOUT_USEC = 4000000 +MUXER_BATCH_TIMEOUT_USEC = 33000 TILED_OUTPUT_WIDTH = 1280 TILED_OUTPUT_HEIGHT = 720 COLORS = [[128, 128, 64], [0, 0, 128], [0, 128, 128], [128, 0, 0], @@ -208,7 +208,7 @@ def main(args): streammux.set_property('width', 1920) streammux.set_property('height', 1080) streammux.set_property('batch-size', 1) - streammux.set_property('batched-push-timeout', 4000000) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) seg.set_property('config-file-path', config_file) pgie_batch_size = seg.get_property("batch-size") if pgie_batch_size != num_sources: diff --git a/apps/deepstream-ssd-parser/README b/apps/deepstream-ssd-parser/README index ac8f529..8bd0b97 100644 --- a/apps/deepstream-ssd-parser/README +++ b/apps/deepstream-ssd-parser/README @@ -16,9 +16,9 @@ ################################################################################ Prequisites: -- DeepStreamSDK 6.3 +- DeepStreamSDK 6.4 - NVIDIA Triton Inference Server -- Python 3.8 +- Python 3.10 - Gst-python - NumPy diff --git a/apps/deepstream-ssd-parser/deepstream_ssd_parser.py b/apps/deepstream-ssd-parser/deepstream_ssd_parser.py index 8f1db26..b084b90 100755 --- a/apps/deepstream-ssd-parser/deepstream_ssd_parser.py +++ b/apps/deepstream-ssd-parser/deepstream_ssd_parser.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -43,7 +43,7 @@ TOP_K = 20 IOU_THRESHOLD = 0.3 OUTPUT_VIDEO_NAME = "./out.mp4" - +MUXER_BATCH_TIMEOUT_USEC = 33000 def get_label_names_from_file(filepath): """ Read a label file and convert it to string list """ @@ -373,7 +373,7 @@ def main(args): streammux.set_property("width", IMAGE_WIDTH) streammux.set_property("height", IMAGE_HEIGHT) streammux.set_property("batch-size", 1) - streammux.set_property("batched-push-timeout", 4000000) + streammux.set_property("batched-push-timeout", MUXER_BATCH_TIMEOUT_USEC) pgie.set_property("config-file-path", "dstest_ssd_nopostprocess.txt") print("Adding elements to Pipeline \n") diff --git a/apps/deepstream-test1-rtsp-out/README b/apps/deepstream-test1-rtsp-out/README index f1dc7a1..bc5d11a 100644 --- a/apps/deepstream-test1-rtsp-out/README +++ b/apps/deepstream-test1-rtsp-out/README @@ -16,8 +16,8 @@ ################################################################################ Prequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python - GstRtspServer @@ -37,6 +37,10 @@ To get test app usage information: To run the test app with default settings: $ python3 deepstream_test1_rtsp_out.py -i + +To run the app on Orin Nano, you must specify the -e 1 option to use SW encoders; +run with -e 0 or leave the option unset to use HW encoders on other Jetson platforms: + $ python3 deepstream_test1_rtsp_out.py -i -e 1 Default RTSP streaming location: rtsp://:8554/ds-test diff --git a/apps/deepstream-test1-rtsp-out/deepstream_test1_rtsp_out.py b/apps/deepstream-test1-rtsp-out/deepstream_test1_rtsp_out.py index 462c4f1..8265ed7 100755 --- a/apps/deepstream-test1-rtsp-out/deepstream_test1_rtsp_out.py +++ b/apps/deepstream-test1-rtsp-out/deepstream_test1_rtsp_out.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,6 +34,7 @@ PGIE_CLASS_ID_BICYCLE = 1 PGIE_CLASS_ID_PERSON = 2 PGIE_CLASS_ID_ROADSIGN = 3 +MUXER_BATCH_TIMEOUT_USEC = 33000 def osd_sink_pad_buffer_probe(pad,info,u_data): frame_number=0 @@ -176,23 +177,32 @@ def main(args): # Create a caps filter caps = Gst.ElementFactory.make("capsfilter", "filter") - caps.set_property("caps", Gst.Caps.from_string("video/x-raw(memory:NVMM), format=I420")) + if enc_type == 0: + caps.set_property("caps", Gst.Caps.from_string("video/x-raw(memory:NVMM), format=I420")) + else: + caps.set_property("caps", Gst.Caps.from_string("video/x-raw, format=I420")) # Make the encoder if codec == "H264": - encoder = Gst.ElementFactory.make("nvv4l2h264enc", "encoder") + if enc_type == 0: + encoder = Gst.ElementFactory.make("nvv4l2h264enc", "encoder") + else: + encoder = Gst.ElementFactory.make("x264enc", "encoder") print("Creating H264 Encoder") elif codec == "H265": - encoder = Gst.ElementFactory.make("nvv4l2h265enc", "encoder") + if enc_type == 0: + encoder = Gst.ElementFactory.make("nvv4l2h265enc", "encoder") + else: + encoder = Gst.ElementFactory.make("x265enc", "encoder") print("Creating H265 Encoder") if not encoder: sys.stderr.write(" Unable to create encoder") encoder.set_property('bitrate', bitrate) - if is_aarch64(): + if is_aarch64() and enc_type == 0: encoder.set_property('preset-level', 1) encoder.set_property('insert-sps-pps', 1) #encoder.set_property('bufapi-version', 1) - + # Make the payload-encode video into RTP packets if codec == "H264": rtppay = Gst.ElementFactory.make("rtph264pay", "rtppay") @@ -219,7 +229,7 @@ def main(args): streammux.set_property('width', 1920) streammux.set_property('height', 1080) streammux.set_property('batch-size', 1) - streammux.set_property('batched-push-timeout', 4000000) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) pgie.set_property('config-file-path', "dstest1_pgie_config.txt") @@ -310,6 +320,8 @@ def parse_args(): help="RTSP Streaming Codec H264/H265 , default=H264", choices=['H264','H265']) parser.add_argument("-b", "--bitrate", default=4000000, help="Set the encoding bitrate ", type=int) + parser.add_argument("-e", "--enc_type", default=0, + help="0:Hardware encoder , 1:Software encoder , default=0", choices=[0, 1], type=int) # Check input arguments if len(sys.argv)==1: parser.print_help(sys.stderr) @@ -318,9 +330,11 @@ def parse_args(): global codec global bitrate global stream_path + global enc_type codec = args.codec bitrate = args.bitrate stream_path = args.input + enc_type = args.enc_type return 0 if __name__ == '__main__': diff --git a/apps/deepstream-test1-rtsp-out/dstest1_pgie_config.txt b/apps/deepstream-test1-rtsp-out/dstest1_pgie_config.txt index 08055f0..a0e4e0f 100644 --- a/apps/deepstream-test1-rtsp-out/dstest1_pgie_config.txt +++ b/apps/deepstream-test1-rtsp-out/dstest1_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,21 +54,28 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 +batch-size=30 +process-mode=1 +model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 diff --git a/apps/deepstream-test1-usbcam/README b/apps/deepstream-test1-usbcam/README index 77160a1..3a83129 100644 --- a/apps/deepstream-test1-usbcam/README +++ b/apps/deepstream-test1-usbcam/README @@ -16,8 +16,8 @@ ################################################################################ Prequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python To run the test app: diff --git a/apps/deepstream-test1-usbcam/deepstream_test_1_usb.py b/apps/deepstream-test1-usbcam/deepstream_test_1_usb.py index 0f10ce3..eaf4459 100755 --- a/apps/deepstream-test1-usbcam/deepstream_test_1_usb.py +++ b/apps/deepstream-test1-usbcam/deepstream_test_1_usb.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,7 +31,7 @@ PGIE_CLASS_ID_BICYCLE = 1 PGIE_CLASS_ID_PERSON = 2 PGIE_CLASS_ID_ROADSIGN = 3 - +MUXER_BATCH_TIMEOUT_USEC = 33000 def osd_sink_pad_buffer_probe(pad,info,u_data): frame_number=0 @@ -213,7 +213,7 @@ def main(args): streammux.set_property('width', 1920) streammux.set_property('height', 1080) streammux.set_property('batch-size', 1) - streammux.set_property('batched-push-timeout', 4000000) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) pgie.set_property('config-file-path', "dstest1_pgie_config.txt") # Set sync = false to avoid late frame drops at the display-sink sink.set_property('sync', False) diff --git a/apps/deepstream-test1-usbcam/dstest1_pgie_config.txt b/apps/deepstream-test1-usbcam/dstest1_pgie_config.txt index f2dfa4a..a0e4e0f 100755 --- a/apps/deepstream-test1-usbcam/dstest1_pgie_config.txt +++ b/apps/deepstream-test1-usbcam/dstest1_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,21 +54,28 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 +batch-size=30 +process-mode=1 +model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 diff --git a/apps/deepstream-test1/README b/apps/deepstream-test1/README index 503819e..c1ec6dc 100644 --- a/apps/deepstream-test1/README +++ b/apps/deepstream-test1/README @@ -16,8 +16,8 @@ ################################################################################ Prequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python To run the test app: diff --git a/apps/deepstream-test1/deepstream_test_1.py b/apps/deepstream-test1/deepstream_test_1.py index a03d326..861cefc 100755 --- a/apps/deepstream-test1/deepstream_test_1.py +++ b/apps/deepstream-test1/deepstream_test_1.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +32,7 @@ PGIE_CLASS_ID_BICYCLE = 1 PGIE_CLASS_ID_PERSON = 2 PGIE_CLASS_ID_ROADSIGN = 3 - +MUXER_BATCH_TIMEOUT_USEC = 33000 def osd_sink_pad_buffer_probe(pad,info,u_data): frame_number=0 @@ -195,7 +195,7 @@ def main(args): if os.environ.get('USE_NEW_NVSTREAMMUX') != 'yes': # Only set these properties if not using new gst-nvstreammux streammux.set_property('width', 1920) streammux.set_property('height', 1080) - streammux.set_property('batched-push-timeout', 4000000) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) streammux.set_property('batch-size', 1) pgie.set_property('config-file-path', "dstest1_pgie_config.txt") diff --git a/apps/deepstream-test1/dstest1_pgie_config.txt b/apps/deepstream-test1/dstest1_pgie_config.txt index 930dbfd..a0e4e0f 100644 --- a/apps/deepstream-test1/dstest1_pgie_config.txt +++ b/apps/deepstream-test1/dstest1_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,21 +54,28 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 +batch-size=30 +process-mode=1 +model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 diff --git a/apps/deepstream-test2/README b/apps/deepstream-test2/README index e99c89a..e3c2acd 100644 --- a/apps/deepstream-test2/README +++ b/apps/deepstream-test2/README @@ -16,7 +16,8 @@ ################################################################################ Prequisites: -- DeepStreamSDK 6.3 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python To run the test app: @@ -40,20 +41,18 @@ considerable behaviors of the instance are parameterized through these configs. For reference, here are the config files used for this sample : 1. The 4-class detector (referred to as pgie in this sample) uses dstest2_pgie_config.txt -2. The vehicle color classifier (referred to as sgie1 in this sample) uses +2. The vehicle make classifier (referred to as sgie1 in this sample) uses dstest2_sgie1_config.txt -3. The vehicle make classifier (referred to as sgie2 in this sample) uses +3. The vehicle type classifier (referred to as sgie2 in this sample) uses dstest2_sgie2_config.txt -4. The vehicle type classifier (referred to as sgie3 in this sample) uses - dstest2_sgie3_config.txt -5. The tracker (referred to as nvtracker in this sample) uses +4. The tracker (referred to as nvtracker in this sample) uses dstest2_tracker_config.txt **DEPRECRATED** To get the past-frame-tracking meta, the following changes have to be added to the dstest2_tracker_config.txt. -1. ll-lib-file=/opt/nvidia/deepstream/deepstream/lib/libnvds_nvdcf.so -2. ll-config-file=tracker_config.yml +1. ll-lib-file=/opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so +2. ll-config-file=config_tracker_NvDCF_perf.yml 3. enable-past-frame=1 In this sample, we first create one instance of "nvinfer", referred as the pgie. diff --git a/apps/deepstream-test2/deepstream_test_2.py b/apps/deepstream-test2/deepstream_test_2.py index 2968db0..e525dc6 100755 --- a/apps/deepstream-test2/deepstream_test_2.py +++ b/apps/deepstream-test2/deepstream_test_2.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,6 +34,7 @@ PGIE_CLASS_ID_BICYCLE = 1 PGIE_CLASS_ID_PERSON = 2 PGIE_CLASS_ID_ROADSIGN = 3 +MUXER_BATCH_TIMEOUT_USEC = 33000 def osd_sink_pad_buffer_probe(pad,info,u_data): frame_number=0 @@ -129,30 +130,30 @@ def osd_sink_pad_buffer_probe(pad,info,u_data): break if(user_meta and user_meta.base_meta.meta_type==pyds.NvDsMetaType.NVDS_TRACKER_PAST_FRAME_META): try: - # Note that user_meta.user_meta_data needs a cast to pyds.NvDsPastFrameObjBatch - # The casting is done by pyds.NvDsPastFrameObjBatch.cast() + # Note that user_meta.user_meta_data needs a cast to pyds.NvDsTargetMiscDataBatch + # The casting is done by pyds.NvDsTargetMiscDataBatch.cast() # The casting also keeps ownership of the underlying memory # in the C code, so the Python garbage collector will leave # it alone - pPastFrameObjBatch = pyds.NvDsPastFrameObjBatch.cast(user_meta.user_meta_data) + pPastDataBatch = pyds.NvDsTargetMiscDataBatch.cast(user_meta.user_meta_data) except StopIteration: break - for trackobj in pyds.NvDsPastFrameObjBatch.list(pPastFrameObjBatch): - print("streamId=",trackobj.streamID) - print("surfaceStreamID=",trackobj.surfaceStreamID) - for pastframeobj in pyds.NvDsPastFrameObjStream.list(trackobj): - print("numobj=",pastframeobj.numObj) - print("uniqueId=",pastframeobj.uniqueId) - print("classId=",pastframeobj.classId) - print("objLabel=",pastframeobj.objLabel) - for objlist in pyds.NvDsPastFrameObjList.list(pastframeobj): - print('frameNum:', objlist.frameNum) - print('tBbox.left:', objlist.tBbox.left) - print('tBbox.width:', objlist.tBbox.width) - print('tBbox.top:', objlist.tBbox.top) - print('tBbox.right:', objlist.tBbox.height) - print('confidence:', objlist.confidence) - print('age:', objlist.age) + for miscDataStream in pyds.NvDsTargetMiscDataBatch.list(pPastDataBatch): + print("streamId=",miscDataStream.streamID) + print("surfaceStreamID=",miscDataStream.surfaceStreamID) + for miscDataObj in pyds.NvDsTargetMiscDataStream.list(miscDataStream): + print("numobj=",miscDataObj.numObj) + print("uniqueId=",miscDataObj.uniqueId) + print("classId=",miscDataObj.classId) + print("objLabel=",miscDataObj.objLabel) + for miscDataFrame in pyds.NvDsTargetMiscDataObject.list(miscDataObj): + print('frameNum:', miscDataFrame.frameNum) + print('tBbox.left:', miscDataFrame.tBbox.left) + print('tBbox.width:', miscDataFrame.tBbox.width) + print('tBbox.top:', miscDataFrame.tBbox.top) + print('tBbox.right:', miscDataFrame.tBbox.height) + print('confidence:', miscDataFrame.confidence) + print('age:', miscDataFrame.age) try: l_user=l_user.next except StopIteration: @@ -220,10 +221,6 @@ def main(args): if not sgie2: sys.stderr.write(" Unable to make sgie2 \n") - sgie3 = Gst.ElementFactory.make("nvinfer", "secondary3-nvinference-engine") - if not sgie3: - sys.stderr.write(" Unable to make sgie3 \n") - nvvidconv = Gst.ElementFactory.make("nvvideoconvert", "convertor") if not nvvidconv: sys.stderr.write(" Unable to create nvvidconv \n") @@ -251,13 +248,12 @@ def main(args): streammux.set_property('width', 1920) streammux.set_property('height', 1080) streammux.set_property('batch-size', 1) - streammux.set_property('batched-push-timeout', 4000000) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) #Set properties of pgie and sgie pgie.set_property('config-file-path', "dstest2_pgie_config.txt") sgie1.set_property('config-file-path', "dstest2_sgie1_config.txt") sgie2.set_property('config-file-path', "dstest2_sgie2_config.txt") - sgie3.set_property('config-file-path', "dstest2_sgie3_config.txt") #Set properties of tracker config = configparser.ConfigParser() @@ -290,7 +286,6 @@ def main(args): pipeline.add(tracker) pipeline.add(sgie1) pipeline.add(sgie2) - pipeline.add(sgie3) pipeline.add(nvvidconv) pipeline.add(nvosd) pipeline.add(sink) @@ -313,8 +308,7 @@ def main(args): pgie.link(tracker) tracker.link(sgie1) sgie1.link(sgie2) - sgie2.link(sgie3) - sgie3.link(nvvidconv) + sgie2.link(nvvidconv) nvvidconv.link(nvosd) nvosd.link(sink) diff --git a/apps/deepstream-test2/dstest2_pgie_config.txt b/apps/deepstream-test2/dstest2_pgie_config.txt index 8563b51..a0e4e0f 100644 --- a/apps/deepstream-test2/dstest2_pgie_config.txt +++ b/apps/deepstream-test2/dstest2_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,23 +54,28 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 -network-mode=1 +batch-size=30 process-mode=1 model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode +network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 diff --git a/apps/deepstream-test2/dstest2_sgie1_config.txt b/apps/deepstream-test2/dstest2_sgie1_config.txt index c6b6535..5ab0cd6 100644 --- a/apps/deepstream-test2/dstest2_sgie1_config.txt +++ b/apps/deepstream-test2/dstest2_sgie1_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,11 @@ [property] gpu-id=0 net-scale-factor=1 -model-file=../../../../samples/models/Secondary_CarColor/resnet18.caffemodel -proto-file=../../../../samples/models/Secondary_CarColor/resnet18.prototxt -model-engine-file=../../../../samples/models/Secondary_CarColor/resnet18.caffemodel_b16_gpu0_int8.engine -mean-file=../../../../samples/models/Secondary_CarColor/mean.ppm -labelfile-path=../../../../samples/models/Secondary_CarColor/labels.txt -int8-calib-file=../../../../samples/models/Secondary_CarColor/cal_trt.bin +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt +model-engine-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt_b16_gpu0_int8.engine +labelfile-path=../../../../samples/models/Secondary_VehicleMake/labels.txt +int8-calib-file=../../../../samples/models/Secondary_VehicleMake/cal_trt.bin force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode @@ -74,9 +73,11 @@ gie-unique-id=2 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 +uff-input-blob-name=input_1 output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 #scaling-compute-hw=0 +infer-dims=3;244;244 diff --git a/apps/deepstream-test2/dstest2_sgie2_config.txt b/apps/deepstream-test2/dstest2_sgie2_config.txt index e436f3d..8b0313b 100644 --- a/apps/deepstream-test2/dstest2_sgie2_config.txt +++ b/apps/deepstream-test2/dstest2_sgie2_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,11 @@ [property] gpu-id=0 net-scale-factor=1 -model-file=../../../../samples/models/Secondary_CarMake/resnet18.caffemodel -proto-file=../../../../samples/models/Secondary_CarMake/resnet18.prototxt -model-engine-file=../../../../samples/models/Secondary_CarMake/resnet18.caffemodel_b16_gpu0_int8.engine -mean-file=../../../../samples/models/Secondary_CarMake/mean.ppm -labelfile-path=../../../../samples/models/Secondary_CarMake/labels.txt -int8-calib-file=../../../../samples/models/Secondary_CarMake/cal_trt.bin +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt +model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt_b16_gpu0_int8.engine +labelfile-path=../../../../samples/models/Secondary_VehicleTypes/labels.txt +int8-calib-file=../../../../samples/models/Secondary_VehicleTypes/cal_trt.bin force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode @@ -74,9 +73,11 @@ gie-unique-id=3 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 +uff-input-blob-name=input_1 output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 #scaling-compute-hw=0 +infer-dims=3;244;244 diff --git a/apps/deepstream-test2/dstest2_sgie3_config.txt b/apps/deepstream-test2/dstest2_sgie3_config.txt deleted file mode 100644 index c3b78c9..0000000 --- a/apps/deepstream-test2/dstest2_sgie3_config.txt +++ /dev/null @@ -1,82 +0,0 @@ -################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -################################################################################ - -# Following properties are mandatory when engine files are not specified: -# int8-calib-file(Only in INT8) -# Caffemodel mandatory properties: model-file, proto-file, output-blob-names -# UFF: uff-file, input-dims, uff-input-blob-name, output-blob-names -# ONNX: onnx-file -# -# Mandatory properties for detectors: -# num-detected-classes -# -# Optional properties for detectors: -# cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0) -# custom-lib-path, -# parse-bbox-func-name -# -# Mandatory properties for classifiers: -# classifier-threshold, is-classifier -# -# Optional properties for classifiers: -# classifier-async-mode(Secondary mode only, Default=false) -# -# Optional properties in secondary mode: -# operate-on-gie-id(Default=0), operate-on-class-ids(Defaults to all classes), -# input-object-min-width, input-object-min-height, input-object-max-width, -# input-object-max-height -# -# Following properties are always recommended: -# batch-size(Default=1) -# -# Other optional properties: -# net-scale-factor(Default=1), network-mode(Default=0 i.e FP32), -# model-color-format(Default=0 i.e. RGB) model-engine-file, labelfile-path, -# mean-file, gie-unique-id(Default=0), offsets, process-mode (Default=1 i.e. primary), -# custom-lib-path, network-mode(Default=0 i.e FP32) -# -# The values in the config file are overridden by values set through GObject -# properties. - -[property] -gpu-id=0 -net-scale-factor=1 -model-file=../../../../samples/models/Secondary_VehicleTypes/resnet18.caffemodel -proto-file=../../../../samples/models/Secondary_VehicleTypes/resnet18.prototxt -model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18.caffemodel_b16_gpu0_int8.engine -mean-file=../../../../samples/models/Secondary_VehicleTypes/mean.ppm -labelfile-path=../../../../samples/models/Secondary_VehicleTypes/labels.txt -int8-calib-file=../../../../samples/models/Secondary_VehicleTypes/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=16 -# 0=FP32 and 1=INT8 mode -network-mode=1 -input-object-min-width=64 -input-object-min-height=64 -model-color-format=1 -process-mode=2 -gpu-id=0 -gie-unique-id=4 -operate-on-gie-id=1 -operate-on-class-ids=0 -is-classifier=1 -output-blob-names=predictions/Softmax -classifier-async-mode=1 -classifier-threshold=0.51 -process-mode=2 -#scaling-filter=0 -#scaling-compute-hw=0 diff --git a/apps/deepstream-test2/dstest2_tracker_config.txt b/apps/deepstream-test2/dstest2_tracker_config.txt index 4768488..622dfe8 100644 --- a/apps/deepstream-test2/dstest2_tracker_config.txt +++ b/apps/deepstream-test2/dstest2_tracker_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,4 +27,4 @@ tracker-width=640 tracker-height=384 gpu-id=0 ll-lib-file=/opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so -ll-config-file=config_tracker_NvDCF_perf.yml \ No newline at end of file +ll-config-file=config_tracker_NvDCF_perf.yml diff --git a/apps/deepstream-test3/README b/apps/deepstream-test3/README index 7d22c4e..87a91e0 100755 --- a/apps/deepstream-test3/README +++ b/apps/deepstream-test3/README @@ -16,9 +16,9 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 6.3 +- DeepStreamSDK 6.4 - NVIDIA Triton Inference Server (optional) -- Python 3.8 +- Python 3.10 - Gst-python To set up Triton Inference Server: (optional) @@ -33,7 +33,7 @@ For x86_64 and Jetson Docker: $ pip3 install pathlib 4. Build and install pyds bindings: Follow the instructions in bindings README in this repo to build and install - pyds wheel for Ubuntu 20.04 + pyds wheel for Ubuntu 22.04 5. For Triton gRPC setup, please follow the instructions at below location: /opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app-triton-grpc/README @@ -44,7 +44,7 @@ For Jetson without Docker: 2.2 Prepare at least the Triton detector models 2. Build and install pyds bindings: Follow the instructions in bindings README in this repo to build and install - pyds wheel for Ubuntu 20.04 + pyds wheel for Ubuntu 22.04 3. Clear the GStreamer cache if pipeline creation fails: rm ~/.cache/gstreamer-1.0/* 4. For Triton gRPC setup, please follow the instructions at below location: @@ -62,7 +62,7 @@ Also follow these instructions for multi-stream Triton support (optional): " enable=1 plugin-type=0 - model-engine-file=../../models/tao_pretrained_models/peopleNet/V2.6/<.engine file> + model-engine-file=../../models/tao_pretrained_models/peopleNet/<.engine file> batch-size= config-file=config_infer_primary_peoplenet.txt " @@ -70,10 +70,10 @@ Also follow these instructions for multi-stream Triton support (optional): For ex. " tlt-model-key=tlt_encode - tlt-encoded-model=../../models/tao_pretrained_models/peopleNet/V2.6/resnet34_peoplenet_int8.etlt + tlt-encoded-model=../../models/tao_pretrained_models/peopleNet/resnet34_peoplenet_int8.etlt labelfile-path=/opt/nvidia/deepstream/deepstream/samples/configs/tao_pretrained_models/labels_peoplenet.txt - model-engine-file=../../models/tao_pretrained_models/peopleNet/V2.6/<.engine file> - int8-calib-file=../../models/tao_pretrained_models/peopleNet/V2.6/resnet34_peoplenet_int8.txt + model-engine-file=../../models/tao_pretrained_models/peopleNet/<.engine file> + int8-calib-file=../../models/tao_pretrained_models/peopleNet/resnet34_peoplenet_int8.txt batch-size=16 " d. While inside the dir /opt/nvidia/deepstream/deepstream/samples/configs/tao_pretrained_models/ , run the deepstream-app @@ -85,7 +85,7 @@ Also follow these instructions for multi-stream Triton support (optional): e. Create the following dir if not present: sudo mkdir -p /opt/nvidia/deepstream/deepstream/samples/triton_model_repo/peoplenet/1/ - f. Copy engine file from dir /opt/nvidia/deepstream/deepstream/samples/models/tao_pretrained_models/peopleNet/V2.6/ + f. Copy engine file from dir /opt/nvidia/deepstream/deepstream/samples/models/tao_pretrained_models/peopleNet/ to /opt/nvidia/deepstream/deepstream/samples/triton_model_repo/peoplenet/1/ diff --git a/apps/deepstream-test3/config.pbtxt b/apps/deepstream-test3/config.pbtxt index a1acbda..6fda68c 100644 --- a/apps/deepstream-test3/config.pbtxt +++ b/apps/deepstream-test3/config.pbtxt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,28 +19,27 @@ name: "peoplenet" platform: "tensorrt_plan" max_batch_size: 1 -default_model_filename: "resnet34_peoplenet_int8.etlt_b1_gpu0_int8.engine" +default_model_filename: "resnet34_peoplenet_int8.onnx_b1_gpu0_int8.engine" input [ { - name: "input_1" + name: "input_1:0" data_type: TYPE_FP32 - format: FORMAT_NCHW dims: [ 3, 544, 960 ] } ] output [ { - name: "output_bbox/BiasAdd" + name: "output_bbox/BiasAdd:0" data_type: TYPE_FP32 dims: [ 12, 34, 60 ] }, - { - name: "output_cov/Sigmoid" + name: "output_cov/Sigmoid:0" data_type: TYPE_FP32 dims: [ 3, 34, 60 ] } ] + instance_group [ { kind: KIND_GPU @@ -48,3 +47,4 @@ instance_group [ gpus: 0 } ] + diff --git a/apps/deepstream-test3/config_infer_primary_peoplenet.txt b/apps/deepstream-test3/config_infer_primary_peoplenet.txt index 2d7da9f..db8b833 100644 --- a/apps/deepstream-test3/config_infer_primary_peoplenet.txt +++ b/apps/deepstream-test3/config_infer_primary_peoplenet.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,11 +18,11 @@ [property] gpu-id=0 net-scale-factor=0.0039215697906911373 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/tao_pretrained_models/peopleNet/V2.6/resnet34_peoplenet_int8.etlt +#tlt-model-key=tlt_encode +onnx-file=../../../../samples/models/tao_pretrained_models/peopleNet/resnet34_peoplenet_int8.onnx labelfile-path=../../../../samples/configs/tao_pretrained_models/labels_peoplenet.txt -model-engine-file=../../../../samples/models/tao_pretrained_models/peopleNet/V2.6/resnet34_peoplenet_int8.etlt_b1_gpu0_int8.engine -int8-calib-file=../../../../samples/models/tao_pretrained_models/peopleNet/V2.6/resnet34_peoplenet_int8.txt +model-engine-file=../../../../samples/models/tao_pretrained_models/peopleNet/resnet34_peoplenet_int8.onnx_b1_gpu0_int8.engine +int8-calib-file=../../../../samples/models/tao_pretrained_models/peopleNet/resnet34_peoplenet_int8.txt input-dims=3;544;960;0 uff-input-blob-name=input_1 batch-size=1 @@ -34,7 +34,7 @@ num-detected-classes=3 cluster-mode=2 interval=0 gie-unique-id=1 -output-blob-names=output_bbox/BiasAdd;output_cov/Sigmoid +output-blob-names=output_bbox/BiasAdd:0;output_cov/Sigmoid:0 #Use the config params below for dbscan clustering mode #[class-attrs-all] diff --git a/apps/deepstream-test3/config_triton_grpc_infer_primary_peoplenet.txt b/apps/deepstream-test3/config_triton_grpc_infer_primary_peoplenet.txt index ac60f03..d6912cd 100644 --- a/apps/deepstream-test3/config_triton_grpc_infer_primary_peoplenet.txt +++ b/apps/deepstream-test3/config_triton_grpc_infer_primary_peoplenet.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,6 +20,13 @@ infer_config { gpu_ids: [0] max_batch_size: 1 backend { + inputs: [ { + name: "input_1:0" + }] + outputs: [ + {name: "output_bbox/BiasAdd:0"}, + {name: "output_cov/Sigmoid:0"} + ] triton { model_name: "peoplenet" version: -1 @@ -31,9 +38,9 @@ infer_config { } preprocess { - network_format: MEDIA_FORMAT_NONE + network_format: IMAGE_FORMAT_RGB tensor_order: TENSOR_ORDER_LINEAR - tensor_name: "input_1" + tensor_name: "input_1:0" maintain_aspect_ratio: 0 frame_scaling_hw: FRAME_SCALING_HW_DEFAULT frame_scaling_filter: 1 @@ -46,7 +53,7 @@ infer_config { postprocess { labelfile_path: "/opt/nvidia/deepstream/deepstream/samples/configs/tao_pretrained_models/labels_peoplenet.txt" detection { - num_detected_classes: 3 + num_detected_classes: 4 per_class_params { key: 0 value { pre_threshold: 0.4 } @@ -69,3 +76,4 @@ input_control { operate_on_gie_id: -1 interval: 0 } + diff --git a/apps/deepstream-test3/config_triton_infer_primary_peoplenet.txt b/apps/deepstream-test3/config_triton_infer_primary_peoplenet.txt index f3410f5..9645398 100644 --- a/apps/deepstream-test3/config_triton_infer_primary_peoplenet.txt +++ b/apps/deepstream-test3/config_triton_infer_primary_peoplenet.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,6 +20,13 @@ infer_config { gpu_ids: [0] max_batch_size: 1 backend { + inputs: [ { + name: "input_1:0" + }] + outputs: [ + {name: "output_bbox/BiasAdd:0"}, + {name: "output_cov/Sigmoid:0"} + ] triton { model_name: "peoplenet" version: -1 @@ -31,9 +38,9 @@ infer_config { } preprocess { - network_format: MEDIA_FORMAT_NONE + network_format: IMAGE_FORMAT_RGB tensor_order: TENSOR_ORDER_LINEAR - tensor_name: "input_1" + tensor_name: "input_1:0" maintain_aspect_ratio: 0 frame_scaling_hw: FRAME_SCALING_HW_DEFAULT frame_scaling_filter: 1 @@ -46,7 +53,7 @@ infer_config { postprocess { labelfile_path: "/opt/nvidia/deepstream/deepstream/samples/configs/tao_pretrained_models/labels_peoplenet.txt" detection { - num_detected_classes: 3 + num_detected_classes: 4 per_class_params { key: 0 value { pre_threshold: 0.4 } @@ -69,3 +76,4 @@ input_control { operate_on_gie_id: -1 interval: 0 } + diff --git a/apps/deepstream-test3/deepstream_test_3.py b/apps/deepstream-test3/deepstream_test_3.py index d81ec92..75a64d5 100755 --- a/apps/deepstream-test3/deepstream_test_3.py +++ b/apps/deepstream-test3/deepstream_test_3.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -48,7 +48,7 @@ PGIE_CLASS_ID_ROADSIGN = 3 MUXER_OUTPUT_WIDTH=1920 MUXER_OUTPUT_HEIGHT=1080 -MUXER_BATCH_TIMEOUT_USEC=4000000 +MUXER_BATCH_TIMEOUT_USEC = 33000 TILED_OUTPUT_WIDTH=1280 TILED_OUTPUT_HEIGHT=720 GST_CAPS_FEATURES_NVMM="memory:NVMM" @@ -320,7 +320,7 @@ def main(args, requested_pgie=None, config=None, disable_probe=False): streammux.set_property('width', 1920) streammux.set_property('height', 1080) streammux.set_property('batch-size', number_sources) - streammux.set_property('batched-push-timeout', 4000000) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) if requested_pgie == "nvinferserver" and config != None: pgie.set_property('config-file-path', config) elif requested_pgie == "nvinferserver-grpc" and config != None: diff --git a/apps/deepstream-test3/dstest3_pgie_config.txt b/apps/deepstream-test3/dstest3_pgie_config.txt index 3a56e71..a0e4e0f 100755 --- a/apps/deepstream-test3/dstest3_pgie_config.txt +++ b/apps/deepstream-test3/dstest3_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +26,7 @@ # # Optional properties for detectors: # cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0) -# custom-lib-path +# custom-lib-path, # parse-bbox-func-name # # Mandatory properties for classifiers: @@ -54,24 +54,30 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 +batch-size=30 process-mode=1 model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd +#scaling-filter=0 +#scaling-compute-hw=0 cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -topk=20 -nms-iou-threshold=0.5 +eps=0.2 +group-threshold=1 diff --git a/apps/deepstream-test4/README b/apps/deepstream-test4/README index 17185d5..97283ad 100755 --- a/apps/deepstream-test4/README +++ b/apps/deepstream-test4/README @@ -16,38 +16,58 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python -#Deepstream msgbroker supports sending messages to Azure(mqtt) IOThub, kafka and AMQP broker(rabbitmq) +#Deepstream msgbroker supports sending messages to Azure(mqtt) IOThub, kafka, AMQP broker(rabbitmq), hiredis, and Eclipse mosquitto (mqtt) Dependencies ------------ $ sudo apt-get update + $ sudo apt-get install libglib2.0 libglib2.0-dev libssl-dev Azure Iot: ---------- - $ sudo apt-get install -y libcurl4-openssl-dev libssl-dev uuid-dev libglib2.0 libglib2.0-dev + $ sudo apt-get install -y libcurl4-openssl-dev uuid-dev Kafka: ------ - $ sudo apt-get install libglib2.0 libglib2.0-dev $ sudo apt-get install libjansson4 libjansson-dev - $ sudo apt-get install librdkafka1=0.11.3-1build1 + $ sudo apt-get install librdkafka1 AMQP (rabbitmq): ---------------- Install rabbitmq-c library -------------------------- - $ git clone -b v0.8.0 --recursive https://github.com/alanxz/rabbitmq-c.git - $ cd rabbitmq-c - $ mkdir build && cd build - $ cmake .. - $ cmake --build . - $ sudo cp librabbitmq/librabbitmq.so.4 /opt/nvidia/deepstream/deepstream-/lib/ + $ sudo apt-get install librabbitmq-dev + + hiredis: + -------- + Build dependencies with installation instructions: + -------------------------------------------------- + Note that for using TLS/SSL security, make sure to build libhiredis with + SSL suport enabled by using the USE_SSL option as specified in the + README here: https://github.com/redis/hiredis + + $ git clone https://github.com/redis/hiredis.git + $ cd hiredis + $ git checkout tags/v1.2.0 + $ make USE_SSL=1 + $ sudo cp libhiredis* /opt/nvidia/deepstream/deepstream/lib/ + $ sudo ln -sf /opt/nvidia/deepstream/deepstream/lib/libhiredis.so /opt/nvidia/deepstream/deepstream/lib/libhiredis.so.1.1.0 $ sudo ldconfig + mosquitto: + ---------- + $ sudo apt-get install libcjson-dev + + $ wget https://mosquitto.org/files/source/mosquitto-2.0.15.tar.gz + $ tar -xvf mosquitto-2.0.15.tar.gz + $ cd mosquitto-2.0.15 + $ make + $ make install + SETUP: 1.Use --proto-lib or -p command line option to set the path of adaptor library. Adaptor library can be found at /opt/nvidia/deepstream/deepstream-/lib @@ -55,11 +75,15 @@ SETUP: kafka lib - libnvds_kafka_proto.so azure device client - libnvds_azure_proto.so AMQP lib - libnvds_amqp_proto.so + redis lib - libnvds_redis_proto.so + mosquitto lib - libnvds_mqtt_proto.so 2.Use --conn-str command line option as required to set connection to backend server. For Azure - Full Azure connection string For Kafka - Connection string of format: host;port;topic For Amqp - Connection string of format: host;port;username. Password to be provided in cfg_amqp.txt + For Redis - Connection string of format: host;port + For MQTT - Connection string of format: host;port Provide connection string under quotes. e.g. --conn-str="host;port;topic" @@ -78,6 +102,8 @@ SETUP: 6.Use --cfg-file or -c command line option to set adaptor configuration file. This is optional if connection string has all relevent information. + Please see the README for each adapter inside DS_PACKAGE_DIR/sources/libs/*_protocol_adaptor for details on configuration options. + For kafka: use cfg_kafka.txt as a reference. This file is used to define the parition key field to be used while sending messages to the kafka broker. Refer Kafka Protocol Adaptor section in the DeepStream 4.0 Plugin Manual for @@ -103,7 +129,7 @@ SETUP: AND provide the shared_access_key within cfg_azure.txt shared_access_key = - For AMQP, use cfg_amqp.txt as reference. It has the following default options: + For AMQP, use cfg_amqp.txt as reference. It has the following section: [message-broker] password = guest #optional @@ -123,6 +149,11 @@ SETUP: AND provide password within cfg_amqp.txt password = + For redis, use cfg_redis.txt as a reference. See the README at DS_PACKAGE_DIR/sources/libs/redis_protocol_adaptor for details on each config option. + + For MQTT, use cfg_mqtt.txt as a reference. See the README at DS_PACKAGE_DIR/sources/libs/mqtt_protocol_adaptor for details on config options + for the protocol adaptor as well as how to configure the mosquitto broker itself accordingly. For example, how to enable authentication and TLS. + NOTE: - DO NOT delete the line [message-broker] in cfg file. Its the section identifier used for parsing - For Azure & AMQP: @@ -130,14 +161,14 @@ SETUP: OR You can ignore --conn-str commandline option and provide full connection details within cfg file - 7. Enable logging: + 1. Enable logging: Go through the README to setup & enable logs for the messaging libraries(kafka, azure, amqp) $ cat ../../../tools/nvds_logger/README To run: $ python3 deepstream_test_4.py -i -p --conn-str= -s <0/1> -NOTE: More details about the message adapters can be found at README inside DS_PACKAGE_DIR/sources/libs/*_protocol_adaptor +NOTE: More details about the message adapters and setup for each can be found at README inside DS_PACKAGE_DIR/sources/libs/*_protocol_adaptor This document shall describe about the sample deepstream-test4 application. @@ -146,7 +177,9 @@ This sample builds on top of the deepstream-test1 sample to demonstrate how to: * Use "nvmsgconv" and "nvmsgbroker" plugins in the pipeline. * Create NVDS_META_EVENT_MSG type of meta and attach to buffer. * Use NVDS_META_EVENT_MSG for different types of objects e.g. vehicle, person etc. -* Provide copy / free functions if meta data is extended through "extMsg" field. +* copy / free functions if meta data is extended through "extMsg" field have been moved out of the deepstream_test4 python app. +These copy and free functions are available for using/extending inside bindschema.cpp as event_msg_meta_copy_func() and +event_msg_meta_release_func() respectively. "nvmsgconv" plugin uses NVDS_META_EVENT_MSG type of metadata from the buffer and generates the "DeepStream Schema" payload in Json format. Static properties @@ -164,11 +197,11 @@ To do that NvDsEventMsgMeta provides "extMsg" and "extMsgSize" fields. User can create custom structure, fill that structure and assign the pointer of that structure as "extMsg" and set the "extMsgSize" accordingly. If custom object contains fields that can't be simply mem copied then user should -also provide function to copy and free those objects. +also provide/extend the functions to copy - event_msg_meta_copy_func() and free - event_msg_meta_release_func() those objects. Refer generate_event_msg_meta() to know how to use "extMsg" and "extMsgSize" -fields for custom objects and how to provide copy/free function and attach that -object to buffer as metadata. +fields for custom objects and refer to bindschema.cpp to know how to provide copy/free functions. The deepstream_test4 app shows +how to attach that object to buffer as metadata. NOTE: This app by default sends message for first object of every 30th frame. To change the frequency of messages, modify the following line in source code accordingly. diff --git a/apps/deepstream-test4/cfg_amqp.txt b/apps/deepstream-test4/cfg_amqp.txt index 291e09b..62e612a 100755 --- a/apps/deepstream-test4/cfg_amqp.txt +++ b/apps/deepstream-test4/cfg_amqp.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2018-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2018-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,10 +15,11 @@ # limitations under the License. ################################################################################ [message-broker] -password = guest -#optional hostname = localhost -username = guest port = 5672 +username = guest +password = guest exchange = amq.topic topic = topicname +amqp-framesize = 131072 +#amqp-heartbeat = 0 diff --git a/apps/deepstream-test4/cfg_azure.txt b/apps/deepstream-test4/cfg_azure.txt index d453fdd..28416e6 100755 --- a/apps/deepstream-test4/cfg_azure.txt +++ b/apps/deepstream-test4/cfg_azure.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2018-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2018-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/apps/deepstream-test4/cfg_mqtt.txt b/apps/deepstream-test4/cfg_mqtt.txt new file mode 100644 index 0000000..fa2215b --- /dev/null +++ b/apps/deepstream-test4/cfg_mqtt.txt @@ -0,0 +1,29 @@ +################################################################################ +# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ + +[message-broker] +username = user +password = password +client-id = uniqueID +#enable-tls = 1 +#tls-cafile = +#tls-capath = +#tls-certfile = +#tls-keyfile = +#share-connection = 1 +#loop-timeout = 2000 +#keep-alive = 60 \ No newline at end of file diff --git a/apps/deepstream-test4/cfg_redis.txt b/apps/deepstream-test4/cfg_redis.txt new file mode 100644 index 0000000..9ac15c2 --- /dev/null +++ b/apps/deepstream-test4/cfg_redis.txt @@ -0,0 +1,25 @@ +################################################################################ +# SPDX-FileCopyrightText: Copyright (c) 2020-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ + +[message-broker] +#hostname=localhost +#port=6379 +#streamsize=10000 +#payloadkey=metadata +#consumergroup=mygroup +#consumername=myname +#share-connection = 1 diff --git a/apps/deepstream-test4/deepstream_test_4.py b/apps/deepstream-test4/deepstream_test_4.py index b22cc64..f471992 100755 --- a/apps/deepstream-test4/deepstream_test_4.py +++ b/apps/deepstream-test4/deepstream_test_4.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,7 +39,7 @@ PGIE_CLASS_ID_ROADSIGN = 3 MUXER_OUTPUT_WIDTH = 1920 MUXER_OUTPUT_HEIGHT = 1080 -MUXER_BATCH_TIMEOUT_USEC = 4000000 +MUXER_BATCH_TIMEOUT_USEC = 33000 input_file = None schema_type = 0 proto_lib = None @@ -53,99 +53,6 @@ pgie_classes_str = ["Vehicle", "TwoWheeler", "Person", "Roadsign"] - -# Callback function for deep-copying an NvDsEventMsgMeta struct -def meta_copy_func(data, user_data): - # Cast data to pyds.NvDsUserMeta - user_meta = pyds.NvDsUserMeta.cast(data) - src_meta_data = user_meta.user_meta_data - # Cast src_meta_data to pyds.NvDsEventMsgMeta - srcmeta = pyds.NvDsEventMsgMeta.cast(src_meta_data) - # Duplicate the memory contents of srcmeta to dstmeta - # First use pyds.get_ptr() to get the C address of srcmeta, then - # use pyds.memdup() to allocate dstmeta and copy srcmeta into it. - # pyds.memdup returns C address of the allocated duplicate. - dstmeta_ptr = pyds.memdup(pyds.get_ptr(srcmeta), - sys.getsizeof(pyds.NvDsEventMsgMeta)) - # Cast the duplicated memory to pyds.NvDsEventMsgMeta - dstmeta = pyds.NvDsEventMsgMeta.cast(dstmeta_ptr) - - # Duplicate contents of ts field. Note that reading srcmeat.ts - # returns its C address. This allows to memory operations to be - # performed on it. - dstmeta.ts = pyds.memdup(srcmeta.ts, MAX_TIME_STAMP_LEN + 1) - - # Copy the sensorStr. This field is a string property. The getter (read) - # returns its C address. The setter (write) takes string as input, - # allocates a string buffer and copies the input string into it. - # pyds.get_string() takes C address of a string and returns the reference - # to a string object and the assignment inside the binder copies content. - dstmeta.sensorStr = pyds.get_string(srcmeta.sensorStr) - - if srcmeta.objSignature.size > 0: - dstmeta.objSignature.signature = pyds.memdup( - srcmeta.objSignature.signature, srcmeta.objSignature.size) - dstmeta.objSignature.size = srcmeta.objSignature.size - - if srcmeta.extMsgSize > 0: - if srcmeta.objType == pyds.NvDsObjectType.NVDS_OBJECT_TYPE_VEHICLE: - srcobj = pyds.NvDsVehicleObject.cast(srcmeta.extMsg) - obj = pyds.alloc_nvds_vehicle_object() - obj.type = pyds.get_string(srcobj.type) - obj.make = pyds.get_string(srcobj.make) - obj.model = pyds.get_string(srcobj.model) - obj.color = pyds.get_string(srcobj.color) - obj.license = pyds.get_string(srcobj.license) - obj.region = pyds.get_string(srcobj.region) - dstmeta.extMsg = obj - dstmeta.extMsgSize = sys.getsizeof(pyds.NvDsVehicleObject) - if srcmeta.objType == pyds.NvDsObjectType.NVDS_OBJECT_TYPE_PERSON: - srcobj = pyds.NvDsPersonObject.cast(srcmeta.extMsg) - obj = pyds.alloc_nvds_person_object() - obj.age = srcobj.age - obj.gender = pyds.get_string(srcobj.gender) - obj.cap = pyds.get_string(srcobj.cap) - obj.hair = pyds.get_string(srcobj.hair) - obj.apparel = pyds.get_string(srcobj.apparel) - dstmeta.extMsg = obj - dstmeta.extMsgSize = sys.getsizeof(pyds.NvDsVehicleObject) - - return dstmeta - - -# Callback function for freeing an NvDsEventMsgMeta instance -def meta_free_func(data, user_data): - user_meta = pyds.NvDsUserMeta.cast(data) - srcmeta = pyds.NvDsEventMsgMeta.cast(user_meta.user_meta_data) - - # pyds.free_buffer takes C address of a buffer and frees the memory - # It's a NOP if the address is NULL - pyds.free_buffer(srcmeta.ts) - pyds.free_buffer(srcmeta.sensorStr) - - if srcmeta.objSignature.size > 0: - pyds.free_buffer(srcmeta.objSignature.signature) - srcmeta.objSignature.size = 0 - - if srcmeta.extMsgSize > 0: - if srcmeta.objType == pyds.NvDsObjectType.NVDS_OBJECT_TYPE_VEHICLE: - obj = pyds.NvDsVehicleObject.cast(srcmeta.extMsg) - pyds.free_buffer(obj.type) - pyds.free_buffer(obj.color) - pyds.free_buffer(obj.make) - pyds.free_buffer(obj.model) - pyds.free_buffer(obj.license) - pyds.free_buffer(obj.region) - if srcmeta.objType == pyds.NvDsObjectType.NVDS_OBJECT_TYPE_PERSON: - obj = pyds.NvDsPersonObject.cast(srcmeta.extMsg) - pyds.free_buffer(obj.gender) - pyds.free_buffer(obj.cap) - pyds.free_buffer(obj.hair) - pyds.free_buffer(obj.apparel) - pyds.free_gbuffer(srcmeta.extMsg) - srcmeta.extMsgSize = 0 - - def generate_vehicle_meta(data): obj = pyds.NvDsVehicleObject.cast(data) obj.type = "sedan" @@ -282,29 +189,25 @@ def osd_sink_pad_buffer_probe(pad, info, u_data): # Frequency of messages to be send will be based on use case. # Here message is being sent for first object every 30 frames. - # Allocating an NvDsEventMsgMeta instance and getting - # reference to it. The underlying memory is not manged by - # Python so that downstream plugins can access it. Otherwise - # the garbage collector will free it when this probe exits. - msg_meta = pyds.alloc_nvds_event_msg_meta() - msg_meta.bbox.top = obj_meta.rect_params.top - msg_meta.bbox.left = obj_meta.rect_params.left - msg_meta.bbox.width = obj_meta.rect_params.width - msg_meta.bbox.height = obj_meta.rect_params.height - msg_meta.frameId = frame_number - msg_meta.trackingId = long_to_uint64(obj_meta.object_id) - msg_meta.confidence = obj_meta.confidence - msg_meta = generate_event_msg_meta(msg_meta, obj_meta.class_id) user_event_meta = pyds.nvds_acquire_user_meta_from_pool( batch_meta) if user_event_meta: + # Allocating an NvDsEventMsgMeta instance and getting + # reference to it. The underlying memory is not manged by + # Python so that downstream plugins can access it. Otherwise + # the garbage collector will free it when this probe exits. + msg_meta = pyds.alloc_nvds_event_msg_meta(user_event_meta) + msg_meta.bbox.top = obj_meta.rect_params.top + msg_meta.bbox.left = obj_meta.rect_params.left + msg_meta.bbox.width = obj_meta.rect_params.width + msg_meta.bbox.height = obj_meta.rect_params.height + msg_meta.frameId = frame_number + msg_meta.trackingId = long_to_uint64(obj_meta.object_id) + msg_meta.confidence = obj_meta.confidence + msg_meta = generate_event_msg_meta(msg_meta, obj_meta.class_id) + user_event_meta.user_meta_data = msg_meta user_event_meta.base_meta.meta_type = pyds.NvDsMetaType.NVDS_EVENT_MSG_META - # Setting callbacks in the event msg meta. The bindings - # layer will wrap these callables in C functions. - # Currently only one set of callbacks is supported. - pyds.user_copyfunc(user_event_meta, meta_copy_func) - pyds.user_releasefunc(user_event_meta, meta_free_func) pyds.nvds_add_user_meta_to_frame(frame_meta, user_event_meta) else: @@ -329,9 +232,14 @@ def osd_sink_pad_buffer_probe(pad, info, u_data): def main(args): Gst.init(None) - # registering callbacks - pyds.register_user_copyfunc(meta_copy_func) - pyds.register_user_releasefunc(meta_free_func) + # Deprecated: following meta_copy_func and meta_free_func + # have been moved to the binding as event_msg_meta_copy_func() + # and event_msg_meta_release_func() respectively. + # Hence, registering and unsetting these callbacks in not needed + # anymore. Please extend the above functions as necessary instead. + # # registering callbacks + # pyds.register_user_copyfunc(meta_copy_func) + # pyds.register_user_releasefunc(meta_free_func) print("Creating Pipeline \n ") @@ -413,7 +321,7 @@ def main(args): streammux.set_property('width', 1920) streammux.set_property('height', 1080) streammux.set_property('batch-size', 1) - streammux.set_property('batched-push-timeout', 4000000) + streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC) pgie.set_property('config-file-path', PGIE_CONFIG_FILE) msgconv.set_property('config', MSCONV_CONFIG_FILE) msgconv.set_property('payload-type', schema_type) @@ -489,7 +397,8 @@ def main(args): except: pass # cleanup - pyds.unset_callback_funcs() + + #pyds.unset_callback_funcs() pipeline.set_state(Gst.State.NULL) diff --git a/apps/deepstream-test4/dstest4_pgie_config.txt b/apps/deepstream-test4/dstest4_pgie_config.txt index 3071b5e..a0e4e0f 100755 --- a/apps/deepstream-test4/dstest4_pgie_config.txt +++ b/apps/deepstream-test4/dstest4_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2018-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,23 +54,28 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 +batch-size=30 +process-mode=1 +model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 -process-mode=1 -model-color-format=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 diff --git a/apps/runtime_source_add_delete/README b/apps/runtime_source_add_delete/README index 98b6223..5e3e2c3 100644 --- a/apps/runtime_source_add_delete/README +++ b/apps/runtime_source_add_delete/README @@ -16,8 +16,8 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 6.3 -- Python 3.8 +- DeepStreamSDK 6.4 +- Python 3.10 - Gst-python To run the test app: diff --git a/apps/runtime_source_add_delete/deepstream_rt_src_add_del.py b/apps/runtime_source_add_delete/deepstream_rt_src_add_del.py index 1ed7988..c3dc1f6 100644 --- a/apps/runtime_source_add_delete/deepstream_rt_src_add_del.py +++ b/apps/runtime_source_add_delete/deepstream_rt_src_add_del.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -41,7 +41,7 @@ PGIE_CLASS_ID_ROADSIGN = 3 MUXER_OUTPUT_WIDTH=1920 MUXER_OUTPUT_HEIGHT=1080 -MUXER_BATCH_TIMEOUT_USEC=4000000 +MUXER_BATCH_TIMEOUT_USEC = 33000 TILED_OUTPUT_WIDTH=1280 TILED_OUTPUT_HEIGHT=720 GPU_ID = 0 @@ -52,7 +52,6 @@ SGIE1_CONFIG_FILE = "dstest_sgie1_config.txt" SGIE2_CONFIG_FILE = "dstest_sgie2_config.txt" -SGIE3_CONFIG_FILE = "dstest_sgie3_config.txt" CONFIG_GPU_ID = "gpu-id" CONFIG_GROUP_TRACKER = "tracker" @@ -78,7 +77,6 @@ pgie = None sgie1 = None sgie2 = None -sgie3 = None nvvideoconvert = None nvosd = None tiler = None @@ -316,7 +314,6 @@ def main(args): global pgie global sgie1 global sgie2 - global sgie3 global nvvideoconvert global nvosd global tiler @@ -401,10 +398,6 @@ def main(args): if not sgie1: sys.stderr.write(" Unable to make sgie2 \n") - sgie3 = Gst.ElementFactory.make("nvinfer", "secondary3-nvinference-engine") - if not sgie3: - sys.stderr.write(" Unable to make sgie3 \n") - if is_aarch64(): print("Creating nv3dsink \n") @@ -423,11 +416,10 @@ def main(args): #Set streammux width and height streammux.set_property('width', MUXER_OUTPUT_WIDTH) streammux.set_property('height', MUXER_OUTPUT_HEIGHT) - #Set pgie, sgie1, sgie2, and sgie3 configuration file paths + #Set pgie, sgie1, and sgie2 configuration file paths pgie.set_property('config-file-path', PGIE_CONFIG_FILE) sgie1.set_property('config-file-path', SGIE1_CONFIG_FILE) sgie2.set_property('config-file-path', SGIE2_CONFIG_FILE) - sgie3.set_property('config-file-path', SGIE3_CONFIG_FILE) #Set properties of tracker config = configparser.ConfigParser() @@ -464,7 +456,6 @@ def main(args): pgie.set_property("gpu_id", GPU_ID) sgie1.set_property("gpu_id", GPU_ID) sgie2.set_property("gpu_id", GPU_ID) - sgie3.set_property("gpu_id", GPU_ID) #Set tiler properties tiler_rows=int(math.sqrt(num_sources)) @@ -488,7 +479,6 @@ def main(args): pipeline.add(tracker) pipeline.add(sgie1) pipeline.add(sgie2) - pipeline.add(sgie3) pipeline.add(tiler) pipeline.add(nvvideoconvert) pipeline.add(nvosd) @@ -502,8 +492,7 @@ def main(args): pgie.link(tracker) tracker.link(sgie1) sgie1.link(sgie2) - sgie2.link(sgie3) - sgie3.link(tiler) + sgie2.link(tiler) tiler.link(nvvideoconvert) nvvideoconvert.link(nvosd) nvosd.link(sink) diff --git a/apps/runtime_source_add_delete/dstest_pgie_config.txt b/apps/runtime_source_add_delete/dstest_pgie_config.txt index 6082b87..0cf6e19 100644 --- a/apps/runtime_source_add_delete/dstest_pgie_config.txt +++ b/apps/runtime_source_add_delete/dstest_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,10 +54,10 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b30_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 @@ -69,7 +69,14 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd +#scaling-filter=0 +#scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #parse-bbox-func-name=NvDsInferParseCustomResnet #custom-lib-path=/path/to/libnvdsparsebbox.so #enable-dbscan=1 diff --git a/apps/runtime_source_add_delete/dstest_sgie1_config.txt b/apps/runtime_source_add_delete/dstest_sgie1_config.txt index f894319..2a0acf6 100644 --- a/apps/runtime_source_add_delete/dstest_sgie1_config.txt +++ b/apps/runtime_source_add_delete/dstest_sgie1_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,11 @@ [property] gpu-id=0 net-scale-factor=1 -model-file=../../../../samples/models/Secondary_CarColor/resnet18.caffemodel -proto-file=../../../../samples/models/Secondary_CarColor/resnet18.prototxt -mean-file=../../../../samples/models/Secondary_CarColor/mean.ppm -labelfile-path=../../../../samples/models/Secondary_CarColor/labels.txt -int8-calib-file=../../../../samples/models/Secondary_CarColor/cal_trt.bin -model-engine-file=../../../../samples/models/Secondary_CarColor/resnet18.caffemodel_b16_gpu0_int8.engine +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt +model-engine-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt_b16_gpu0_int8.engine +labelfile-path=../../../../samples/models/Secondary_VehicleMake/labels.txt +int8-calib-file=../../../../samples/models/Secondary_VehicleMake/cal_trt.bin force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode @@ -74,7 +73,11 @@ gie-unique-id=2 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 +uff-input-blob-name=input_1 output-blob-names=predictions/Softmax -classifier-async-mode=0 +classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 +#scaling-filter=0 +#scaling-compute-hw=0 +infer-dims=3;244;244 diff --git a/apps/runtime_source_add_delete/dstest_sgie2_config.txt b/apps/runtime_source_add_delete/dstest_sgie2_config.txt index 44135f3..57aa4b2 100644 --- a/apps/runtime_source_add_delete/dstest_sgie2_config.txt +++ b/apps/runtime_source_add_delete/dstest_sgie2_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,11 @@ [property] gpu-id=0 net-scale-factor=1 -model-file=../../../../samples/models/Secondary_CarMake/resnet18.caffemodel -proto-file=../../../../samples/models/Secondary_CarMake/resnet18.prototxt -mean-file=../../../../samples/models/Secondary_CarMake/mean.ppm -labelfile-path=../../../../samples/models/Secondary_CarMake/labels.txt -int8-calib-file=../../../../samples/models/Secondary_CarMake/cal_trt.bin -model-engine-file=../../../../samples/models/Secondary_CarMake/resnet18.caffemodel_b16_gpu0_int8.engine +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt +model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt_b16_gpu0_int8.engine +labelfile-path=../../../../samples/models/Secondary_VehicleTypes/labels.txt +int8-calib-file=../../../../samples/models/Secondary_VehicleTypes/cal_trt.bin force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode @@ -74,7 +73,11 @@ gie-unique-id=3 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 +uff-input-blob-name=input_1 output-blob-names=predictions/Softmax -classifier-async-mode=0 +classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 +#scaling-filter=0 +#scaling-compute-hw=0 +infer-dims=3;244;244 diff --git a/apps/runtime_source_add_delete/dstest_sgie3_config.txt b/apps/runtime_source_add_delete/dstest_sgie3_config.txt deleted file mode 100644 index 65ca525..0000000 --- a/apps/runtime_source_add_delete/dstest_sgie3_config.txt +++ /dev/null @@ -1,80 +0,0 @@ -################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -################################################################################ - -# Following properties are mandatory when engine files are not specified: -# int8-calib-file(Only in INT8) -# Caffemodel mandatory properties: model-file, proto-file, output-blob-names -# UFF: uff-file, input-dims, uff-input-blob-name, output-blob-names -# ONNX: onnx-file -# -# Mandatory properties for detectors: -# num-detected-classes -# -# Optional properties for detectors: -# cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0) -# custom-lib-path, -# parse-bbox-func-name -# -# Mandatory properties for classifiers: -# classifier-threshold, is-classifier -# -# Optional properties for classifiers: -# classifier-async-mode(Secondary mode only, Default=false) -# -# Optional properties in secondary mode: -# operate-on-gie-id(Default=0), operate-on-class-ids(Defaults to all classes), -# input-object-min-width, input-object-min-height, input-object-max-width, -# input-object-max-height -# -# Following properties are always recommended: -# batch-size(Default=1) -# -# Other optional properties: -# net-scale-factor(Default=1), network-mode(Default=0 i.e FP32), -# model-color-format(Default=0 i.e. RGB) model-engine-file, labelfile-path, -# mean-file, gie-unique-id(Default=0), offsets, process-mode (Default=1 i.e. primary), -# custom-lib-path, network-mode(Default=0 i.e FP32) -# -# The values in the config file are overridden by values set through GObject -# properties. - -[property] -gpu-id=0 -net-scale-factor=1 -model-file=../../../../samples/models/Secondary_VehicleTypes/resnet18.caffemodel -proto-file=../../../../samples/models/Secondary_VehicleTypes/resnet18.prototxt -mean-file=../../../../samples/models/Secondary_VehicleTypes/mean.ppm -labelfile-path=../../../../samples/models/Secondary_VehicleTypes/labels.txt -int8-calib-file=../../../../samples/models/Secondary_VehicleTypes/cal_trt.bin -model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18.caffemodel_b16_gpu0_int8.engine -force-implicit-batch-dim=1 -batch-size=16 -# 0=FP32 and 1=INT8 mode -network-mode=1 -input-object-min-width=64 -input-object-min-height=64 -model-color-format=1 -process-mode=2 -gpu-id=0 -gie-unique-id=4 -operate-on-gie-id=1 -operate-on-class-ids=0 -is-classifier=1 -output-blob-names=predictions/Softmax -classifier-async-mode=0 -classifier-threshold=0.51 -process-mode=2 diff --git a/apps/runtime_source_add_delete/dstest_tracker_config.txt b/apps/runtime_source_add_delete/dstest_tracker_config.txt index d1008a0..d722d45 100644 --- a/apps/runtime_source_add_delete/dstest_tracker_config.txt +++ b/apps/runtime_source_add_delete/dstest_tracker_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/bindings/BINDINGSGUIDE.md b/bindings/BINDINGSGUIDE.md index c1f2fd5..253cb44 100644 --- a/bindings/BINDINGSGUIDE.md +++ b/bindings/BINDINGSGUIDE.md @@ -527,12 +527,15 @@ py::class_(m, "NvDsEventMsgMeta", STRING_PROPERTY(NvDsEventMsgMeta, sensorStr)) ... ``` -Then, in the [deep copy function](https://github.com/NVIDIA-AI-IOT/deepstream_python_apps/blob/master/apps/deepstream-test4/deepstream_test_4.py#L83) -where ```dstmeta``` is the newly allocated ```NvDsEventMsgMeta``` object, and ```srcmeta``` is the ```NvDsEventMsgMeta``` object to be copied: +Then, in the [streammux src pad probe function](https://github.com/NVIDIA-AI-IOT/deepstream_python_apps/blob/master/apps/deepstream-custom-binding-test/deepstream_custom_binding_test.py#L70) +where ```data``` is the newly allocated ```CustomDataStruct``` object, and ```test_string``` is the python string object to be copied: ``` -dstmeta.sensorStr = pyds.get_string(srcmeta.sensorStr) +test_string = 'test message ' + str(frame_number) +data = pyds.alloc_custom_struct(user_meta) +data.message = test_string # python string object at first +data.message = pyds.get_string(data.message) ``` -```srcmeta.sensorStr``` calls the getter function defined in the string property, which returns the C address of the string, which is then passed into the ```get_string``` method. The assignment operator passes the resulting string reference into the setter function for ```dstmeta.sensorStr```, which allocates memory for the C string and copies in the content of the string. +```data.message``` calls the getter function defined in the string property, which returns the C address of the string, which is then passed into the ```get_string``` method. The assignment operator passes the resulting string reference into the setter function for ```data.message```, which allocates memory for the C string and copies in the content of the string. ### How to write docstrings Docstrings should be declared and defined as a ```constexpr const char*``` in a header file under [```docstrings/```](docstrings/) corresponding to the header to which the binding belongs. All docstrings belong under the ```pydsdoc::{header_name}doc``` namespace. The final documentation is generated with [Sphinx](https://www.sphinx-doc.org/en/master/index.html), so docstrings must follow .rst format and use Sphinx [directives](https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html). diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index d89d5e8..de3ccc7 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -23,7 +23,7 @@ function(check_variable_set variable_name default_value) endfunction() check_variable_set(PYTHON_MAJOR_VERSION 3) -check_variable_set(PYTHON_MINOR_VERSION 8) +check_variable_set(PYTHON_MINOR_VERSION 10) check_variable_set(PIP_PLATFORM linux_x86_64) check_variable_set(DS_PATH "/opt/nvidia/deepstream/deepstream") @@ -36,7 +36,7 @@ macro(check_variable_allowed var_name var_list) endmacro() set(PYTHON_MAJVERS_ALLOWED 3) check_variable_allowed(PYTHON_MAJOR_VERSION PYTHON_MAJVERS_ALLOWED) -set(PYTHON_MINVERS_ALLOWED 6 8) +set(PYTHON_MINVERS_ALLOWED 10) check_variable_allowed(PYTHON_MINOR_VERSION PYTHON_MINVERS_ALLOWED) set(PIP_PLATFORM_ALLOWED linux_x86_64 linux_aarch64) check_variable_allowed(PIP_PLATFORM PIP_PLATFORM_ALLOWED) @@ -49,7 +49,7 @@ set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined") # Setting python build versions set(PYTHON_VERSION ${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}) -set(PIP_WHEEL pyds-1.1.8-py3-none-${PIP_PLATFORM}.whl) +set(PIP_WHEEL pyds-1.1.10-py3-none-${PIP_PLATFORM}.whl) # Describing pyds build project(pyds DESCRIPTION "Python bindings for Deepstream") @@ -79,9 +79,6 @@ set_target_properties(pyds PROPERTIES PREFIX "") set_target_properties(pyds PROPERTIES OUTPUT_NAME "pyds") set(PYTHON_LIB python${PYTHON_VERSION}) -if(${PYTHON_MINOR_VERSION} EQUAL 6) - set(PYTHON_LIB python${PYTHON_VERSION}m) -endif() target_link_libraries(pyds pthread dl ${PYTHON_LIB} gstreamer-1.0 glib-2.0) diff --git a/bindings/README.md b/bindings/README.md index e0e6a10..9cbeefd 100644 --- a/bindings/README.md +++ b/bindings/README.md @@ -1,6 +1,6 @@ # DeepStream python bindings -SDK version supported: 6.3 +SDK version supported: 6.4 The latest prebuilt release package complete with python bindings and sample applications can be downloaded from the [release section](../../../releases) for both x86 and Jetson platforms. @@ -15,14 +15,14 @@ The readme is divided into three main parts: - [1.3 Initialization of submodules](#13-initialization-of-submodules) - [1.4 Installing Gst-python](#14-installing-gst-python) - [2 Compiling the bindings](#2-compiling-the-bindings) - - [2.1 Quick build (x86-ubuntu-20.04 | python 3.8 | Deepstream 6.3)](#21-quick-build-x86-ubuntu-2004--python-38--deepstream-63) + - [2.1 Quick build (x86-ubuntu-22.04 | python 3.10 | Deepstream 6.4)](#21-quick-build-x86-ubuntu-2204--python-310--deepstream-64) - [2.2 Advanced build](#22-advanced-build) - [2.2.1 Using Cmake options](#221-using-cmake-options) - [2.2.2 Available cmake options](#222-available-cmake-options) - [2.2.3 Example](#223-example) - [2.3 Cross-Compilation for aarch64 on x86](#23-cross-compilation-for-aarch64-on-x86) - [2.3.1 Build Pre-requisites](#231-build-pre-requisites) - - [2.3.2 Download the JetPack SDK 5.1.2](#232-download-the-jetpack-sdk-512) + - [2.3.2 Download the JetPack SDK 6.0 DP](#232-download-the-jetpack-sdk-60-dp) - [2.3.3 Generate the cross-compile build container](#233-generate-the-cross-compile-build-container) - [2.3.4 Launch the cross-compile build container](#234-launch-the-cross-compile-build-container) - [2.3.5 Build DeepStreamSDK python bindings](#235-build-deepstreamsdk-python-bindings) @@ -42,21 +42,21 @@ Go to https://developer.nvidia.com/deepstream-sdk, download and install Deepstre ### 1.2 Base dependencies -To compile bindings on Ubuntu - 20.04 [use python-3.8, python-3.6 will not work] : +To compile bindings on Ubuntu - 22.04 [use python-3.10, python-3.8 will not work] : ``` -apt install python3-gi python3-dev python3-gst-1.0 python-gi-dev git \ - python3 python3-pip python3.8-dev cmake g++ build-essential libglib2.0-dev \ +apt install python3-gi python3-dev python3-gst-1.0 python-gi-dev git meson \ + python3 python3-pip python3.10-dev cmake g++ build-essential libglib2.0-dev \ libglib2.0-dev-bin libgstreamer1.0-dev libtool m4 autoconf automake libgirepository1.0-dev libcairo2-dev ``` ### 1.3 Initialization of submodules -Make sure you clone the deepstream_python_apps repo under /sources: +Make sure you clone the deepstream_python_apps repo under /sources: git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps This will create the following directory: ``` -/sources/deepstream_python_apps +/sources/deepstream_python_apps ``` The repository utilizes gst-python and pybind11 submodules. @@ -76,10 +76,12 @@ sudo update-ca-certificates Build and install gst-python: ```bash -cd 3rdparty/gst-python/ -./autogen.sh -make -sudo make install +cd 3rdparty/gstreamer/subprojects/gst-python/ +meson build +meson configure +cd build +ninja +ninja install ``` @@ -88,7 +90,7 @@ Python bindings are compiled using CMake. Following commands provide quick cmake configurations for common compilation options: -### 2.1 Quick build (x86-ubuntu-20.04 | python 3.8 | Deepstream 6.3) +### 2.1 Quick build (x86-ubuntu-22.04 | python 3.10 | Deepstream 6.4) ```bash cd deepstream_python_apps/bindings mkdir build @@ -110,9 +112,9 @@ cmake .. [-D= [-D= [-D= ... ]]] | Var | Default value | Purpose | Available values |-----|:-------------:|---------|:----------------: -| DS_VERSION | 6.3 | Used to determine default deepstream library path | should match to the deepstream version installed on your computer +| DS_VERSION | 6.4 | Used to determine default deepstream library path | should match to the deepstream version installed on your computer | PYTHON_MAJOR_VERSION | 3 | Used to set the python version used for the bindings | 3 -| PYTHON_MINOR_VERSION | 8 | Used to set the python version used for the bindings | 6, 8 +| PYTHON_MINOR_VERSION | 10 | Used to set the python version used for the bindings | 10 | PIP_PLATFORM | linux_x86_64 | Used to select the target architecture to compile the bindings | linux_x86_64, linux_aarch64 | DS_PATH | /opt/nvidia/deepstream/deepstream-${DS_VERSION} | Path where deepstream libraries are available | Should match the existing deepstream library folder @@ -124,7 +126,7 @@ Following commands can be used to compile the bindings natively on Jetson device cd deepstream_python_apps/bindings mkdir build cd build -cmake .. -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=8 \ +cmake .. -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=10 \ -DPIP_PLATFORM=linux_aarch64 -DDS_PATH=/opt/nvidia/deepstream/deepstream/ make ``` @@ -148,17 +150,17 @@ sudo apt-get install qemu binfmt-support qemu-user-static docker run --rm --privileged dockerhub.nvidia.com/multiarch/qemu-user-static --reset -p yes # Verify qemu installation -docker run --rm -t nvcr.io/nvidia/deepstream-l4t:6.3-samples uname -m +docker run --platform linux/aarch64 --rm -t nvcr.io/nvidia/deepstream:6.4-samples-multiarch uname -m #aarch64 ``` -#### 2.3.2 Download the JetPack SDK 5.1.2 +#### 2.3.2 Download the JetPack SDK 6.0 DP Cross-compilation for Jetson on x86 host requires some low level libraries which can be downloaded using SDK Manager. Follow these steps to obtain these libraries, which are utilized by the docker build later. 1. Download and install the [NVIDIA SDK manager](https://developer.nvidia.com/nvidia-sdk-manager) 2. Launch the SDK Manager and login with your NVIDIA developer account. -3. Select the platform and target OS (example: Jetson AGX Xavier, `Linux Jetpack 5.1.2`) and click Continue. +3. Select the platform and target OS (example: Jetson AGX Xavier, `Linux Jetpack 6.0 DP`) and click Continue. 4. Under `Download & Install Options` change the download folder and select `Download now, Install later`. Agree to the license terms and click Continue. 5. Go to the download folder, and run: @@ -179,7 +181,7 @@ Below command generates the build container cd deepstream_python_apps/bindings # Make sure you are in deepstream_python_apps/bindings directory # This command builds the cross-compile docker and adds the mentioned tag -docker build --tag=deepstream-6.3-ubuntu20.04-python-l4t -f qemu_docker/ubuntu-cross-aarch64.Dockerfile . +docker build --platform linux/aarch64 --tag=deepstream-6.4-ubuntu22.04-python-l4t -f qemu_docker/ubuntu-cross-aarch64.Dockerfile . ``` #### 2.3.4 Launch the cross-compile build container @@ -189,7 +191,7 @@ docker build --tag=deepstream-6.3-ubuntu20.04-python-l4t -f qemu_docker/ubuntu-c mkdir export_pyds # Run the container. Make sure the tag matches the one from Generate step above -docker run -it --entrypoint bash -v $PWD/export_pyds:/export_pyds deepstream-6.3-ubuntu20.04-python-l4t +docker run --platform linux/aarch64 -it --entrypoint bash -v $PWD/export_pyds:/export_pyds deepstream-6.4-ubuntu22.04-python-l4t ``` #### 2.3.5 Build DeepStreamSDK python bindings @@ -212,7 +214,7 @@ git submodule update --init mkdir build && cd build # Run cmake with following options -cmake .. -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=8 -DPIP_PLATFORM=linux_aarch64 -DDS_PATH=/opt/nvidia/deepstream/deepstream +cmake .. -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=10 -DPIP_PLATFORM=linux_aarch64 -DDS_PATH=/opt/nvidia/deepstream/deepstream # Build pybind wheel and pyds.so make -j$(nproc) @@ -230,7 +232,7 @@ Following commands can be used to install the generated pip wheel. ### 3.1 Installing the pip wheel ```bash -pip3 install ./pyds-1.1.8-py3-none*.whl +pip3 install ./pyds-1.1.10-py3-none*.whl ``` #### 3.1.1 pip wheel troubleshooting diff --git a/bindings/docstrings/functionsdoc.h b/bindings/docstrings/functionsdoc.h index fd11509..531d092 100644 --- a/bindings/docstrings/functionsdoc.h +++ b/bindings/docstrings/functionsdoc.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -438,6 +438,8 @@ namespace pydsdoc constexpr const char* alloc_nvds_event_msg_meta=R"pyds( Allocate an :class:`NvDsEventMsgMeta`. + :arg user_meta: An object of type :class:`NvDsUserMeta` acquired from user_meta_pool present in :class:`NvDsBatchMeta` + :returns: Allocated :class:`NvDsEventMsgMeta`)pyds"; constexpr const char* alloc_nvds_event=R"pyds( diff --git a/bindings/docstrings/schemadoc.h b/bindings/docstrings/schemadoc.h index 49bf24c..e9b7882 100644 --- a/bindings/docstrings/schemadoc.h +++ b/bindings/docstrings/schemadoc.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -298,28 +298,25 @@ namespace pydsdoc ... - # Allocating an NvDsEventMsgMeta instance and getting reference - # to it. The underlying memory is not manged by Python so that - # downstream plugins can access it. Otherwise the garbage collector - # will free it when this probe exits. - msg_meta=pyds.alloc_nvds_event_msg_meta() - msg_meta.bbox.top = obj_meta.rect_params.top - msg_meta.bbox.left = obj_meta.rect_params.left - msg_meta.bbox.width = obj_meta.rect_params.width - msg_meta.bbox.height = obj_meta.rect_params.height - msg_meta.frameId = frame_number - msg_meta.trackingId = long_to_uint64(obj_meta.object_id) - msg_meta.confidence = obj_meta.confidence - msg_meta = generate_event_msg_meta(msg_meta, obj_meta.class_id) user_event_meta = pyds.nvds_acquire_user_meta_from_pool(batch_meta) if(user_event_meta): + # Allocating an NvDsEventMsgMeta instance and getting reference + # to it. The underlying memory is not manged by Python so that + # downstream plugins can access it. Otherwise the garbage collector + # will free it when this probe exits. + msg_meta=pyds.alloc_nvds_event_msg_meta(user_event_meta) + msg_meta.bbox.top = obj_meta.rect_params.top + msg_meta.bbox.left = obj_meta.rect_params.left + msg_meta.bbox.width = obj_meta.rect_params.width + msg_meta.bbox.height = obj_meta.rect_params.height + msg_meta.frameId = frame_number + msg_meta.trackingId = long_to_uint64(obj_meta.object_id) + msg_meta.confidence = obj_meta.confidence + msg_meta = generate_event_msg_meta(msg_meta, obj_meta.class_id) + user_event_meta.user_meta_data = msg_meta; user_event_meta.base_meta.meta_type = pyds.NvDsMetaType.NVDS_EVENT_MSG_META - # Setting callbacks in the event msg meta. The bindings layer - # will wrap these callables in C functions. Currently only one - # set of callbacks is supported. - pyds.user_copyfunc(user_event_meta, meta_copy_func) - pyds.user_releasefunc(user_event_meta, meta_free_func) + pyds.nvds_add_user_meta_to_frame(frame_meta, user_event_meta) else: print("Error in attaching event meta to buffer\n"))pyds"; diff --git a/bindings/docstrings/trackermetadoc.h b/bindings/docstrings/trackermetadoc.h index 0aa1435..4a35840 100644 --- a/bindings/docstrings/trackermetadoc.h +++ b/bindings/docstrings/trackermetadoc.h @@ -21,10 +21,10 @@ namespace pydsdoc { namespace trackerdoc { - namespace NvDsPastFrameObjDoc //missing doxygen comments + namespace NvDsTargetMiscDataFrameDoc //missing doxygen comments { constexpr const char* descr = R"pyds( - NvDsPastFrameObj + NvDsTargetMiscDataFrame :ivar frameNum: *int*, frameNum :ivar tBbox: :class:`NvOSD_RectParams`, tBbox @@ -47,26 +47,26 @@ namespace pydsdoc break if(user_meta and user_meta.base_meta.meta_type==pyds.NvDsMetaType.NVDS_TRACKER_PAST_FRAME_META): #Make sure metatype is correct try: - # Note that user_meta.user_meta_data needs a cast to pyds.NvDsPastFrameObjBatch - # The casting is done by pyds.NvDsPastFrameObjBatch.cast() + # Note that user_meta.user_meta_data needs a cast to pyds.NvDsTargetMiscDataBatch + # The casting is done by pyds.NvDsTargetMiscDataBatch.cast() # The casting also keeps ownership of the underlying memory # in the C code, so the Python garbage collector will leave # it alone - pPastFrameObjBatch = pyds.NvDsPastFrameObjBatch.cast(user_meta.user_meta_data) #See NvDsPastFrameObjBatch for details + pPastFrameObjBatch = pyds.NvDsTargetMiscDataBatch.cast(user_meta.user_meta_data) #See NvDsTargetMiscDataBatch for details except StopIteration: break - for trackobj in pyds.NvDsPastFrameObjBatch.list(pPastFrameObjBatch): #Iterate through list of NvDsPastFrameObjStream objects - #Access NvDsPastFrameObjStream attributes + for trackobj in pyds.NvDsTargetMiscDataBatch.list(pPastFrameObjBatch): #Iterate through list of NvDsTargetMiscDataStream objects + #Access NvDsTargetMiscDataStream attributes print("streamId=",trackobj.streamID) print("surfaceStreamID=",trackobj.surfaceStreamID) - for pastframeobj in pyds.NvDsPastFrameObjStream.list(trackobj): #Iterate through list of NvDsFrameObjList objects - #Access NvDsPastFrameObjList attributes + for pastframeobj in pyds.NvDsTargetMiscDataStream.list(trackobj): #Iterate through list of NvDsFrameObjList objects + #Access NvDsTargetMiscDataObject attributes print("numobj=",pastframeobj.numObj) print("uniqueId=",pastframeobj.uniqueId) print("classId=",pastframeobj.classId) print("objLabel=",pastframeobj.objLabel) - for objlist in pyds.NvDsPastFrameObjList.list(pastframeobj): #Iterate through list of NvDsFrameObj objects - #Access NvDsPastFrameObj attributes + for objlist in pyds.NvDsTargetMiscDataObject.list(pastframeobj): #Iterate through list of NvDsFrameObj objects + #Access NvDsTargetMiscDataFrame attributes print('frameNum:', objlist.frameNum) print('tBbox.left:', objlist.tBbox.left) print('tBbox.width:', objlist.tBbox.width) @@ -79,48 +79,48 @@ namespace pydsdoc except StopIteration: break)pyds"; - constexpr const char* cast=R"pyds(cast given object/data to :class:`NvDsPastFrameObj`, call pyds.NvDsPastFrameObj.cast(data))pyds"; + constexpr const char* cast=R"pyds(cast given object/data to :class:`NvDsTargetMiscDataFrame`, call pyds.NvDsTargetMiscDataFrame.cast(data))pyds"; } - namespace NvDsPastFrameObjListDoc + namespace NvDsTargetMiscDataObjectDoc { constexpr const char* descr = R"pyds( - One object in several past frames. See :class:`NvDsPastFrameObj` for example usage. + One object in several past frames. See :class:`NvDsTargetMiscDataFrame` for example usage. :ivar numObj: *int*, Number of frames this object appreared in the past. :ivar uniqueId: *int*, Object tracking id. :ivar classID: *int*, Object class id. :ivar objLabel: An array of the string describing the object class.)pyds"; - constexpr const char* list=R"pyds(Retrieve :class:`NvDsPastFrameObjList` object as list of :class:`NvDsPastFrameObj`. Contains past frame info of this object.)pyds"; - constexpr const char* cast=R"pyds(cast given object/data to :class:`NvDsPastFrameObjList`, call pyds.NvDsPastFrameObjList.cast(data))pyds"; + constexpr const char* list=R"pyds(Retrieve :class:`NvDsTargetMiscDataObject` object as list of :class:`NvDsTargetMiscDataFrame`. Contains past frame info of this object.)pyds"; + constexpr const char* cast=R"pyds(cast given object/data to :class:`NvDsTargetMiscDataObject`, call pyds.NvDsTargetMiscDataObject.cast(data))pyds"; } - namespace NvDsPastFrameObjStreamDoc + namespace NvDsTargetMiscDataStreamDoc { constexpr const char* descr = R"pyds( - List of objects in each stream. See :class:`NvDsPastFrameObj` for example usage. + List of objects in each stream. See :class:`NvDsTargetMiscDataFrame` for example usage. :ivar streamID: *int*, Stream id the same as frame_meta->pad_index. :ivar surfaceStreamID: *int*, Stream id used inside tracker plugin. :ivar numAllocated: *int*, Maximum number of objects allocated. :ivar numFilled: *int*, Number of objects in this frame.)pyds"; - constexpr const char* list=R"pyds(Retrieve :class:`NvDsPastFrameObjStream` object as list of :class:`NvDsPastFrameObjList`. Contains objects inside this stream.)pyds"; - constexpr const char* cast=R"pyds(cast given object/data to :class:`NvDsPastFrameObjStream`, call pyds.NvDsPastFrameObjStream.cast(data))pyds"; + constexpr const char* list=R"pyds(Retrieve :class:`NvDsTargetMiscDataStream` object as list of :class:`NvDsTargetMiscDataObject`. Contains objects inside this stream.)pyds"; + constexpr const char* cast=R"pyds(cast given object/data to :class:`NvDsTargetMiscDataStream`, call pyds.NvDsTargetMiscDataStream.cast(data))pyds"; } - namespace NvDsPastFrameObjBatchDoc + namespace NvDsTargetMiscDataBatchDoc { constexpr const char* descr = R"pyds( - Batch of lists of buffered objects. See :class:`NvDsPastFrameObj` for example usage. + Batch of lists of buffered objects. See :class:`NvDsTargetMiscDataFrame` for example usage. :ivar numAllocated: *int*, Number of blocks allocated for the list. :ivar numFilled: *int*, Number of filled blocks in the list. )pyds"; - constexpr const char* list=R"pyds(Retrieve :class:`NvDsPastFrameObjBatch` object as list of :class:`NvDsPastFrameObjStream`. Contains stream lists.)pyds"; - constexpr const char* cast=R"pyds(cast given object/data to :class:`NvDsPastFrameObjBatch`, call pyds.NvDsPastFrameObjBatch.cast(data))pyds"; + constexpr const char* list=R"pyds(Retrieve :class:`NvDsTargetMiscDataBatch` object as list of :class:`NvDsTargetMiscDataStream`. Contains stream lists.)pyds"; + constexpr const char* cast=R"pyds(cast given object/data to :class:`NvDsTargetMiscDataBatch`, call pyds.NvDsTargetMiscDataBatch.cast(data))pyds"; } } diff --git a/bindings/packaging/setup.py b/bindings/packaging/setup.py index 284e6cf..2b4f533 100644 --- a/bindings/packaging/setup.py +++ b/bindings/packaging/setup.py @@ -17,7 +17,7 @@ setuptools.setup( name="pyds", - version="1.1.8", + version="1.1.10", author="NVIDIA", description="Install precompiled DeepStream Python bindings extension", url="nvidia.com", diff --git a/bindings/qemu_docker/ubuntu-cross-aarch64.Dockerfile b/bindings/qemu_docker/ubuntu-cross-aarch64.Dockerfile index aeff85b..78c0841 100644 --- a/bindings/qemu_docker/ubuntu-cross-aarch64.Dockerfile +++ b/bindings/qemu_docker/ubuntu-cross-aarch64.Dockerfile @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM nvcr.io/nvidia/deepstream-l4t:6.3-samples +FROM nvcr.io/nvidia/deepstream:6.4-samples-multiarch LABEL maintainer="NVIDIA CORPORATION" # Set timezone. @@ -74,7 +74,7 @@ COPY docker/jetpack_files/Jetson*Linux_R*aarch64.tbz2 /bsp_files/ # Copy libs from BSP RUN cd /bsp_files \ - && tar -jxpf Jetson*Linux_R35*aarch64.tbz2 \ + && tar -jxpf Jetson*Linux_R3*aarch64.tbz2 \ && cd Linux_for_Tegra/nv_tegra \ && tar -jxpf nvidia_drivers.tbz2 \ && cp -aprf usr/lib/aarch64-linux-gnu/tegra/libnvbuf*.so.1.0.0 /opt/nvidia/deepstream/deepstream/lib/ \ diff --git a/bindings/src/bindschema.cpp b/bindings/src/bindschema.cpp index 9b7b7da..7085d3d 100644 --- a/bindings/src/bindschema.cpp +++ b/bindings/src/bindschema.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,6 +24,145 @@ namespace py = pybind11; namespace pydeepstream { + NvDsEventMsgMeta * event_msg_meta_copy_func(void* data, void* user_data) { + NvDsUserMeta * srcMeta = (NvDsUserMeta*) data; + NvDsEventMsgMeta * srcData = (NvDsEventMsgMeta *) srcMeta->user_meta_data; + NvDsEventMsgMeta * destData = (NvDsEventMsgMeta *) g_malloc0( + sizeof(NvDsEventMsgMeta)); + destData->type = srcData->type; + destData->objType = srcData->objType; + destData->bbox = srcData->bbox; + destData->location = srcData->location; + destData->coordinate = srcData->coordinate; + destData->objSignature = srcData->objSignature; + destData->objClassId = srcData->objClassId; + destData->sensorId = srcData->sensorId; + destData->moduleId = srcData->moduleId; + destData->placeId = srcData->placeId; + destData->componentId = srcData->componentId; + destData->frameId = srcData->frameId; + destData->confidence = srcData->confidence; + destData->trackingId = srcData->trackingId; + + if (srcData->ts != nullptr) { + destData->ts = g_strdup (srcData->ts); + } + + if (srcData->objectId != nullptr) { + destData->objectId = g_strdup (srcData->objectId); + } + + if (srcData->sensorStr != nullptr) { + destData->sensorStr = g_strdup (srcData->sensorStr); + } + + if (srcData->otherAttrs != nullptr) { + destData->otherAttrs = g_strdup (srcData->otherAttrs); + } + + if (srcData->videoPath != nullptr) { + destData->videoPath = g_strdup (srcData->videoPath); + } + + if (srcData->extMsgSize > 0) { + if (srcData->objType == NVDS_OBJECT_TYPE_VEHICLE) { + NvDsVehicleObject *srcObj = (NvDsVehicleObject *) srcData->extMsg; + NvDsVehicleObject *obj = + (NvDsVehicleObject *) g_malloc0 (sizeof (NvDsVehicleObject)); + if (srcObj->type) + obj->type = g_strdup (srcObj->type); + if (srcObj->make) + obj->make = g_strdup (srcObj->make); + if (srcObj->model) + obj->model = g_strdup (srcObj->model); + if (srcObj->color) + obj->color = g_strdup (srcObj->color); + if (srcObj->license) + obj->license = g_strdup (srcObj->license); + if (srcObj->region) + obj->region = g_strdup (srcObj->region); + destData->extMsg = obj; + destData->extMsgSize = sizeof (NvDsVehicleObject); + } else if (srcData->objType == NVDS_OBJECT_TYPE_PERSON) { + NvDsPersonObject *srcObj = (NvDsPersonObject *) srcData->extMsg; + NvDsPersonObject *obj = + (NvDsPersonObject *) g_malloc0 (sizeof (NvDsPersonObject)); + obj->age = srcObj->age; + if (srcObj->gender) + obj->gender = g_strdup (srcObj->gender); + if (srcObj->cap) + obj->cap = g_strdup (srcObj->cap); + if (srcObj->hair) + obj->hair = g_strdup (srcObj->hair); + if (srcObj->apparel) + obj->apparel = g_strdup (srcObj->apparel); + destData->extMsg = obj; + destData->extMsgSize = sizeof (NvDsPersonObject); + } + } + + return destData; + } + + void event_msg_meta_release_func(void * data, void * user_data) { + NvDsUserMeta * srcMeta = (NvDsUserMeta*) data; + if (srcMeta != nullptr) { + NvDsEventMsgMeta * srcData = (NvDsEventMsgMeta *) srcMeta->user_meta_data; + if (srcData != nullptr) { + if (srcData->ts != nullptr) { + g_free(srcData->ts); + srcData->ts = NULL; + } + if (srcData->objectId != nullptr) { + g_free(srcData->objectId); + srcData->objectId = NULL; + } + if (srcData->sensorStr != nullptr) { + g_free(srcData->sensorStr); + srcData->sensorStr = NULL; + } + if (srcData->otherAttrs != nullptr) { + g_free(srcData->otherAttrs); + srcData->otherAttrs = NULL; + } + + if (srcData->videoPath != nullptr) { + g_free(srcData->videoPath); + srcData->videoPath = NULL; + } + + if (srcData->extMsgSize > 0) { + if (srcData->objType == NVDS_OBJECT_TYPE_VEHICLE) { + NvDsVehicleObject *obj = (NvDsVehicleObject *) srcData->extMsg; + if (obj->type) + g_free (obj->type); + if (obj->color) + g_free (obj->color); + if (obj->make) + g_free (obj->make); + if (obj->model) + g_free (obj->model); + if (obj->license) + g_free (obj->license); + if (obj->region) + g_free (obj->region); + } else if (srcData->objType == NVDS_OBJECT_TYPE_PERSON) { + NvDsPersonObject *obj = (NvDsPersonObject *) srcData->extMsg; + if (obj->gender) + g_free (obj->gender); + if (obj->cap) + g_free (obj->cap); + if (obj->hair) + g_free (obj->hair); + if (obj->apparel) + g_free (obj->apparel); + } + g_free (srcData->extMsg); + srcData->extMsgSize = 0; + } + } + } + } void bindschema(py::module &m) { /*Start of Bindings for nvdsmeta_schema.h*/ py::enum_(m, "NvDsEventType", @@ -424,9 +563,11 @@ namespace pydeepstream { .def_readwrite("extMsgSize", &NvDsEventMsgMeta::extMsgSize); m.def("alloc_nvds_event_msg_meta", - []() { + [](NvDsUserMeta *user_meta) { auto *msg_meta = (NvDsEventMsgMeta *) g_malloc0( sizeof(NvDsEventMsgMeta)); + user_meta->base_meta.copy_func = (NvDsMetaCopyFunc) pydeepstream::event_msg_meta_copy_func; + user_meta->base_meta.release_func = (NvDsMetaReleaseFunc) pydeepstream::event_msg_meta_release_func; return msg_meta; }, py::return_value_policy::reference, diff --git a/bindings/src/bindtrackermeta.cpp b/bindings/src/bindtrackermeta.cpp index e77da33..672e7bb 100644 --- a/bindings/src/bindtrackermeta.cpp +++ b/bindings/src/bindtrackermeta.cpp @@ -26,94 +26,94 @@ namespace pydeepstream { void bindtrackermeta(py::module &m) { /*Start of Bindings for nvds_tracker_meta.h*/ - py::class_(m, "NvDsPastFrameObj", - pydsdoc::trackerdoc::NvDsPastFrameObjDoc::descr) + py::class_(m, "NvDsTargetMiscDataFrame", + pydsdoc::trackerdoc::NvDsTargetMiscDataFrameDoc::descr) .def(py::init<>()) - .def_readwrite("frameNum", &NvDsPastFrameObj::frameNum) - .def_readwrite("tBbox", &NvDsPastFrameObj::tBbox) - .def_readwrite("confidence", &NvDsPastFrameObj::confidence) - .def_readwrite("age", &NvDsPastFrameObj::age) + .def_readwrite("frameNum", &NvDsTargetMiscDataFrame::frameNum) + .def_readwrite("tBbox", &NvDsTargetMiscDataFrame::tBbox) + .def_readwrite("confidence", &NvDsTargetMiscDataFrame::confidence) + .def_readwrite("age", &NvDsTargetMiscDataFrame::age) .def("cast", [](void *data) { - return (NvDsPastFrameObj *) data; + return (NvDsTargetMiscDataFrame *) data; }, py::return_value_policy::reference, - pydsdoc::trackerdoc::NvDsPastFrameObjDoc::cast); + pydsdoc::trackerdoc::NvDsTargetMiscDataFrameDoc::cast); - py::class_(m, "NvDsPastFrameObjList", - pydsdoc::trackerdoc::NvDsPastFrameObjListDoc::descr) + py::class_(m, "NvDsTargetMiscDataObject", + pydsdoc::trackerdoc::NvDsTargetMiscDataObjectDoc::descr) .def(py::init<>()) - .def_readwrite("numObj", &NvDsPastFrameObjList::numObj) - .def_readwrite("uniqueId", &NvDsPastFrameObjList::uniqueId) - .def_readwrite("classId", &NvDsPastFrameObjList::classId) + .def_readwrite("numObj", &NvDsTargetMiscDataObject::numObj) + .def_readwrite("uniqueId", &NvDsTargetMiscDataObject::uniqueId) + .def_readwrite("classId", &NvDsTargetMiscDataObject::classId) .def_property("objLabel", - STRING_CHAR_ARRAY(NvDsPastFrameObjList, objLabel)) + STRING_CHAR_ARRAY(NvDsTargetMiscDataObject, objLabel)) .def("cast", [](void *data) { - return (NvDsPastFrameObjList *) data; + return (NvDsTargetMiscDataObject *) data; }, py::return_value_policy::reference, - pydsdoc::trackerdoc::NvDsPastFrameObjListDoc::cast) + pydsdoc::trackerdoc::NvDsTargetMiscDataObjectDoc::cast) .def("list", - [](NvDsPastFrameObjList &self) { + [](NvDsTargetMiscDataObject &self) { return py::make_iterator(self.list, self.list + self.numObj); }, py::keep_alive<0, 1>(), py::return_value_policy::reference, - pydsdoc::trackerdoc::NvDsPastFrameObjListDoc::list); + pydsdoc::trackerdoc::NvDsTargetMiscDataObjectDoc::list); - py::class_(m, "NvDsPastFrameObjStream", - pydsdoc::trackerdoc::NvDsPastFrameObjStreamDoc::descr) + py::class_(m, "NvDsTargetMiscDataStream", + pydsdoc::trackerdoc::NvDsTargetMiscDataStreamDoc::descr) .def(py::init<>()) - .def_readwrite("streamID", &NvDsPastFrameObjStream::streamID) + .def_readwrite("streamID", &NvDsTargetMiscDataStream::streamID) .def_readwrite("surfaceStreamID", - &NvDsPastFrameObjStream::surfaceStreamID) + &NvDsTargetMiscDataStream::surfaceStreamID) .def_readwrite("numAllocated", - &NvDsPastFrameObjStream::numAllocated) - .def_readwrite("numFilled", &NvDsPastFrameObjStream::numFilled) + &NvDsTargetMiscDataStream::numAllocated) + .def_readwrite("numFilled", &NvDsTargetMiscDataStream::numFilled) .def("cast", [](void *data) { - return (NvDsPastFrameObjStream *) data; + return (NvDsTargetMiscDataStream *) data; }, py::return_value_policy::reference, - pydsdoc::trackerdoc::NvDsPastFrameObjStreamDoc::cast) + pydsdoc::trackerdoc::NvDsTargetMiscDataStreamDoc::cast) .def("list", - [](NvDsPastFrameObjStream &self) { + [](NvDsTargetMiscDataStream &self) { return py::make_iterator(self.list, self.list + self.numFilled); }, py::keep_alive<0, 1>(), py::return_value_policy::reference, - pydsdoc::trackerdoc::NvDsPastFrameObjStreamDoc::list); + pydsdoc::trackerdoc::NvDsTargetMiscDataStreamDoc::list); - py::class_(m, "NvDsPastFrameObjBatch", - pydsdoc::trackerdoc::NvDsPastFrameObjBatchDoc::descr) + py::class_(m, "NvDsTargetMiscDataBatch", + pydsdoc::trackerdoc::NvDsTargetMiscDataBatchDoc::descr) .def(py::init<>()) .def_readwrite("numAllocated", - &NvDsPastFrameObjBatch::numAllocated) - .def_readwrite("numFilled", &NvDsPastFrameObjBatch::numFilled) + &NvDsTargetMiscDataBatch::numAllocated) + .def_readwrite("numFilled", &NvDsTargetMiscDataBatch::numFilled) .def("cast", [](void *data) { - return (NvDsPastFrameObjBatch *) data; + return (NvDsTargetMiscDataBatch *) data; }, py::return_value_policy::reference, - pydsdoc::trackerdoc::NvDsPastFrameObjBatchDoc::cast) + pydsdoc::trackerdoc::NvDsTargetMiscDataBatchDoc::cast) .def("list", - [](NvDsPastFrameObjBatch &self) { + [](NvDsTargetMiscDataBatch &self) { return py::make_iterator(self.list, self.list + self.numFilled); }, py::keep_alive<0, 1>(), py::return_value_policy::reference, - pydsdoc::trackerdoc::NvDsPastFrameObjBatchDoc::list); + pydsdoc::trackerdoc::NvDsTargetMiscDataBatchDoc::list); } diff --git a/bindings/src/custom_binding/bindcustom.cpp b/bindings/src/custom_binding/bindcustom.cpp index a401d59..5e0a253 100644 --- a/bindings/src/custom_binding/bindcustom.cpp +++ b/bindings/src/custom_binding/bindcustom.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,7 +24,7 @@ namespace py = pybind11; namespace pydeepstream { - void * copy_custom_struct(void* data, void* user_data) { + CustomDataStruct * copy_custom_struct(void* data, void* user_data) { NvDsUserMeta * srcMeta = (NvDsUserMeta*) data; CustomDataStruct * srcData = (CustomDataStruct *) srcMeta->user_meta_data; CustomDataStruct *destData = (CustomDataStruct *) g_malloc0( diff --git a/bindings/src/pyds.cpp b/bindings/src/pyds.cpp index 529db2a..00406a4 100644 --- a/bindings/src/pyds.cpp +++ b/bindings/src/pyds.cpp @@ -35,7 +35,7 @@ #include */ -#define PYDS_VERSION "1.1.8" +#define PYDS_VERSION "1.1.10" using namespace std; namespace py = pybind11; diff --git a/docs/conf.py b/docs/conf.py index 6dfddf7..d69249a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,7 +38,7 @@ project = 'Deepstream' copyright = '2019-2023, NVIDIA.' author = 'NVIDIA' -version = 'Deepstream Version: 6.3' +version = 'Deepstream Version: 6.4' release = version diff --git a/notebooks/configs/config_tracker_NvDCF_perf.yml b/notebooks/configs/config_tracker_NvDCF_perf.yml new file mode 100644 index 0000000..056090d --- /dev/null +++ b/notebooks/configs/config_tracker_NvDCF_perf.yml @@ -0,0 +1,74 @@ +%YAML:1.0 +################################################################################ +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ + +BaseConfig: + minDetectorConfidence: 0 # If the confidence of a detector bbox is lower than this, then it won't be considered for tracking + +TargetManagement: + enableBboxUnClipping: 1 # In case the bbox is likely to be clipped by image border, unclip bbox + maxTargetsPerStream: 150 # Max number of targets to track per stream. Recommended to set >10. Note: this value should account for the targets being tracked in shadow mode as well. Max value depends on the GPU memory capacity + + # [Creation & Termination Policy] + minIouDiff4NewTarget: 0.5 # If the IOU between the newly detected object and any of the existing targets is higher than this threshold, this newly detected object will be discarded. + minTrackerConfidence: 0.2 # If the confidence of an object tracker is lower than this on the fly, then it will be tracked in shadow mode. Valid Range: [0.0, 1.0] + probationAge: 3 # If the target's age exceeds this, the target will be considered to be valid. + maxShadowTrackingAge: 30 # Max length of shadow tracking. If the shadowTrackingAge exceeds this limit, the tracker will be terminated. + earlyTerminationAge: 1 # If the shadowTrackingAge reaches this threshold while in TENTATIVE period, the target will be terminated prematurely. + +TrajectoryManagement: + useUniqueID: 0 # Use 64-bit long Unique ID when assignining tracker ID. Default is [true] + +DataAssociator: + dataAssociatorType: 0 # the type of data associator among { DEFAULT= 0 } + associationMatcherType: 0 # the type of matching algorithm among { GREEDY=0, GLOBAL=1 } + checkClassMatch: 1 # If checked, only the same-class objects are associated with each other. Default: true + + # [Association Metric: Thresholds for valid candidates] + minMatchingScore4Overall: 0.0 # Min total score + minMatchingScore4SizeSimilarity: 0.6 # Min bbox size similarity score + minMatchingScore4Iou: 0.0 # Min IOU score + minMatchingScore4VisualSimilarity: 0.7 # Min visual similarity score + + # [Association Metric: Weights] + matchingScoreWeight4VisualSimilarity: 0.6 # Weight for the visual similarity (in terms of correlation response ratio) + matchingScoreWeight4SizeSimilarity: 0.0 # Weight for the Size-similarity score + matchingScoreWeight4Iou: 0.4 # Weight for the IOU score + +StateEstimator: + stateEstimatorType: 1 # the type of state estimator among { DUMMY=0, SIMPLE=1, REGULAR=2 } + + # [Dynamics Modeling] + processNoiseVar4Loc: 2.0 # Process noise variance for bbox center + processNoiseVar4Size: 1.0 # Process noise variance for bbox size + processNoiseVar4Vel: 0.1 # Process noise variance for velocity + measurementNoiseVar4Detector: 4.0 # Measurement noise variance for detector's detection + measurementNoiseVar4Tracker: 16.0 # Measurement noise variance for tracker's localization + +VisualTracker: + visualTrackerType: 1 # the type of visual tracker among { DUMMY=0, NvDCF=1 } + + # [NvDCF: Feature Extraction] + useColorNames: 1 # Use ColorNames feature + useHog: 0 # Use Histogram-of-Oriented-Gradient (HOG) feature + featureImgSizeLevel: 2 # Size of a feature image. Valid range: {1, 2, 3, 4, 5}, from the smallest to the largest + featureFocusOffsetFactor_y: -0.2 # The offset for the center of hanning window relative to the feature height. The center of hanning window would move by (featureFocusOffsetFactor_y*featureMatSize.height) in vertical direction + + # [NvDCF: Correlation Filter] + filterLr: 0.075 # learning rate for DCF filter in exponential moving average. Valid Range: [0.0, 1.0] + filterChannelWeightsLr: 0.1 # learning rate for the channel weights among feature channels. Valid Range: [0.0, 1.0] + gaussianSigma: 0.75 # Standard deviation for Gaussian for desired response when creating DCF filter [pixels] diff --git a/notebooks/configs/dslaunchpad_pgie_config.txt b/notebooks/configs/dslaunchpad_pgie_config.txt index 930dbfd..26885aa 100644 --- a/notebooks/configs/dslaunchpad_pgie_config.txt +++ b/notebooks/configs/dslaunchpad_pgie_config.txt @@ -54,21 +54,28 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 +batch-size=30 +process-mode=1 +model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 diff --git a/notebooks/configs/dslaunchpad_sgie1_config.txt b/notebooks/configs/dslaunchpad_sgie1_config.txt index c6b6535..1b81b07 100644 --- a/notebooks/configs/dslaunchpad_sgie1_config.txt +++ b/notebooks/configs/dslaunchpad_sgie1_config.txt @@ -55,12 +55,11 @@ [property] gpu-id=0 net-scale-factor=1 -model-file=../../../../samples/models/Secondary_CarColor/resnet18.caffemodel -proto-file=../../../../samples/models/Secondary_CarColor/resnet18.prototxt -model-engine-file=../../../../samples/models/Secondary_CarColor/resnet18.caffemodel_b16_gpu0_int8.engine -mean-file=../../../../samples/models/Secondary_CarColor/mean.ppm -labelfile-path=../../../../samples/models/Secondary_CarColor/labels.txt -int8-calib-file=../../../../samples/models/Secondary_CarColor/cal_trt.bin +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt +model-engine-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt_b16_gpu0_int8.engine +labelfile-path=../../../../samples/models/Secondary_VehicleMake/labels.txt +int8-calib-file=../../../../samples/models/Secondary_VehicleMake/cal_trt.bin force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode @@ -74,9 +73,11 @@ gie-unique-id=2 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 +uff-input-blob-name=input_1 output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 #scaling-compute-hw=0 +infer-dims=3;244;244 \ No newline at end of file diff --git a/notebooks/configs/dslaunchpad_sgie2_config.txt b/notebooks/configs/dslaunchpad_sgie2_config.txt index e436f3d..3e3843d 100644 --- a/notebooks/configs/dslaunchpad_sgie2_config.txt +++ b/notebooks/configs/dslaunchpad_sgie2_config.txt @@ -55,12 +55,11 @@ [property] gpu-id=0 net-scale-factor=1 -model-file=../../../../samples/models/Secondary_CarMake/resnet18.caffemodel -proto-file=../../../../samples/models/Secondary_CarMake/resnet18.prototxt -model-engine-file=../../../../samples/models/Secondary_CarMake/resnet18.caffemodel_b16_gpu0_int8.engine -mean-file=../../../../samples/models/Secondary_CarMake/mean.ppm -labelfile-path=../../../../samples/models/Secondary_CarMake/labels.txt -int8-calib-file=../../../../samples/models/Secondary_CarMake/cal_trt.bin +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt +model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt_b16_gpu0_int8.engine +labelfile-path=../../../../samples/models/Secondary_VehicleTypes/labels.txt +int8-calib-file=../../../../samples/models/Secondary_VehicleTypes/cal_trt.bin force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode @@ -74,9 +73,11 @@ gie-unique-id=3 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 +uff-input-blob-name=input_1 output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 #scaling-compute-hw=0 +infer-dims=3;244;244 diff --git a/notebooks/configs/dslaunchpad_sgie3_config.txt b/notebooks/configs/dslaunchpad_sgie3_config.txt deleted file mode 100644 index c3b78c9..0000000 --- a/notebooks/configs/dslaunchpad_sgie3_config.txt +++ /dev/null @@ -1,82 +0,0 @@ -################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -################################################################################ - -# Following properties are mandatory when engine files are not specified: -# int8-calib-file(Only in INT8) -# Caffemodel mandatory properties: model-file, proto-file, output-blob-names -# UFF: uff-file, input-dims, uff-input-blob-name, output-blob-names -# ONNX: onnx-file -# -# Mandatory properties for detectors: -# num-detected-classes -# -# Optional properties for detectors: -# cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0) -# custom-lib-path, -# parse-bbox-func-name -# -# Mandatory properties for classifiers: -# classifier-threshold, is-classifier -# -# Optional properties for classifiers: -# classifier-async-mode(Secondary mode only, Default=false) -# -# Optional properties in secondary mode: -# operate-on-gie-id(Default=0), operate-on-class-ids(Defaults to all classes), -# input-object-min-width, input-object-min-height, input-object-max-width, -# input-object-max-height -# -# Following properties are always recommended: -# batch-size(Default=1) -# -# Other optional properties: -# net-scale-factor(Default=1), network-mode(Default=0 i.e FP32), -# model-color-format(Default=0 i.e. RGB) model-engine-file, labelfile-path, -# mean-file, gie-unique-id(Default=0), offsets, process-mode (Default=1 i.e. primary), -# custom-lib-path, network-mode(Default=0 i.e FP32) -# -# The values in the config file are overridden by values set through GObject -# properties. - -[property] -gpu-id=0 -net-scale-factor=1 -model-file=../../../../samples/models/Secondary_VehicleTypes/resnet18.caffemodel -proto-file=../../../../samples/models/Secondary_VehicleTypes/resnet18.prototxt -model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18.caffemodel_b16_gpu0_int8.engine -mean-file=../../../../samples/models/Secondary_VehicleTypes/mean.ppm -labelfile-path=../../../../samples/models/Secondary_VehicleTypes/labels.txt -int8-calib-file=../../../../samples/models/Secondary_VehicleTypes/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=16 -# 0=FP32 and 1=INT8 mode -network-mode=1 -input-object-min-width=64 -input-object-min-height=64 -model-color-format=1 -process-mode=2 -gpu-id=0 -gie-unique-id=4 -operate-on-gie-id=1 -operate-on-class-ids=0 -is-classifier=1 -output-blob-names=predictions/Softmax -classifier-async-mode=1 -classifier-threshold=0.51 -process-mode=2 -#scaling-filter=0 -#scaling-compute-hw=0 diff --git a/notebooks/configs/dslaunchpad_tracker_config.txt b/notebooks/configs/dslaunchpad_tracker_config.txt index 4768488..fb20017 100644 --- a/notebooks/configs/dslaunchpad_tracker_config.txt +++ b/notebooks/configs/dslaunchpad_tracker_config.txt @@ -27,4 +27,4 @@ tracker-width=640 tracker-height=384 gpu-id=0 ll-lib-file=/opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so -ll-config-file=config_tracker_NvDCF_perf.yml \ No newline at end of file +ll-config-file=./configs/config_tracker_NvDCF_perf.yml \ No newline at end of file diff --git a/notebooks/deepstream_launchpad.ipynb b/notebooks/deepstream_launchpad.ipynb index b8abadd..b71dd6b 100644 --- a/notebooks/deepstream_launchpad.ipynb +++ b/notebooks/deepstream_launchpad.ipynb @@ -170,7 +170,6 @@ "tracker_config_file = \"./configs/dslaunchpad_tracker_config.txt\" # Path to tracker config file\n", "sgie1_config_file = \"./configs/dslaunchpad_sgie1_config.txt\" # Path to config file for first sgie\n", "sgie2_config_file = \"./configs/dslaunchpad_sgie2_config.txt\" # Path to config file for second sgie\n", - "sgie3_config_file = \"./configs/dslaunchpad_sgie3_config.txt\" # Path to config file for third sgie\n", "\n", "# Tracker options\n", "enable_tracker = 1 # Enable/disable tracker and SGIEs. 0 for disable, 1 for enable\n", @@ -539,7 +538,7 @@ "metadata": {}, "source": [ "### Step 8-2-3 - Create nvinfer element as PGIE\n", - "The Gst-nvinfer plugin takes the batched buffer from the streammux and performs inference using NVIDIA TensorRT. We create this element to perform inference in primary mode. Behaviour of the inference are set through properties in the configuration file. In this case, we are using ResNet10 to detect objects and classify them as Person, Vehicle, Bicycle, or Roadsign." + "The Gst-nvinfer plugin takes the batched buffer from the streammux and performs inference using NVIDIA TensorRT. We create this element to perform inference in primary mode. Behaviour of the inference are set through properties in the configuration file. In this case, we are using ResNet18 to detect objects and classify them as Person, Vehicle, Bicycle, or Roadsign." ] }, { @@ -576,22 +575,27 @@ "```bash\n", "[property]\n", "gpu-id=0 # Device ID of GPU to use for inference\n", - "net-scale-factor=0.0039215697906911373 # Pixel scaling factor\n", - "model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel # Path to caffemodel file\n", - "proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt # Path to prototxt file\n", - "# Path toserialized model engine file\n", - "model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine\n", + "net-scale-factor=0.00392156862745098 # Pixel scaling factor\n", + "tlt-model-key=tlt_encode # Key for the TAO toolkit encoded model.\n", + "tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt # Pathname of the TAO toolkit encoded model.\n", + "model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine # Path to serialized model engine file\n", "labelfile-path=../../../../samples/models/Primary_Detector/labels.txt # Path to text file containing labels\n", "int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin # Path to calibration file\n", "force-implicit-batch-dim=1 # Force the implicit batch dimension mode\n", - "batch-size=1 # Number of frames/objects to be inferred together in a batch\n", - "network-mode=1 # Data format to be used by inference - 0: FP32, 1: INT8, 2: FP16\n", + "batch-size=30 # Number of frames/objects to be inferred together in a batch\n", + "process-mode=1 # Infer Processing Mode 1=Primary Mode 2=Secondary Mode\n", + "model-color-format=0 # Color format required by the model (ignored if input-tensor-meta enabled)\n", + "network-mode=1 # Data format to be used by inference 0=FP32, 1=INT8, 2=FP16 mode\n", "num-detected-classes=4 # Number of classes detected by the network\n", "interval=0 # Number of consecutive batches to be skipped for inference\n", "gie-unique-id=1 # Unique ID to assign to GIE\n", - "output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid # Array of output layer names\n", + "uff-input-order=0 # UFF input layer order\n", + "uff-input-blob-name=input_1 # Name of the input blob in the UFF file\n", + "output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd # Array of output layer names\n", "#scaling-filter=0\n", "#scaling-compute-hw=0\n", + "cluster-mode=2 # Clustering algorithm to use.\n", + "infer-dims=3;544;960 # Binding dimensions to set on the image input layer\n", "\n", "[class-attrs-all]\n", "pre-cluster-threshold=0.2 # Detection threshold to be applied prior to clustering\n", @@ -676,23 +680,14 @@ " sgie2 = Gst.ElementFactory.make(\"nvinfer\", \"secondary2-nvinference-engine\")\n", " if not sgie2:\n", " sys.stderr.write(\" Unable to make sgie2 \\n\")\n", - " \n", - " print(\"Creating nvinfer (SGIE3) \\n \")\n", - " \n", - " # Create nvinfer element\n", - " sgie3 = Gst.ElementFactory.make(\"nvinfer\", \"secondary3-nvinference-engine\")\n", - " if not sgie3:\n", - " sys.stderr.write(\" Unable to make sgie3 \\n\")\n", "\n", " # Set config file for each SGIE\n", " sgie1.set_property('config-file-path', sgie1_config_file)\n", " sgie2.set_property('config-file-path', sgie2_config_file)\n", - " sgie3.set_property('config-file-path', sgie3_config_file)\n", "\n", " # Add SGIEs to pipeline\n", " pipeline.add(sgie1)\n", - " pipeline.add(sgie2)\n", - " pipeline.add(sgie3)" + " pipeline.add(sgie2)" ] }, { @@ -876,13 +871,12 @@ "# Note that the sources were already linked to the streammux\n", "# Link streammux > pgie\n", "streammux.link(pgie)\n", - "# If tracker is enabled, link pgie > tracker > sgie1 > sgie2 > sgie3 > tiler\n", + "# If tracker is enabled, link pgie > tracker > sgie1 > sgie2 > tiler\n", "if enable_tracker:\n", " pgie.link(tracker)\n", " tracker.link(sgie1)\n", " sgie1.link(sgie2)\n", - " sgie2.link(sgie3)\n", - " sgie3.link(tiler)\n", + " sgie2.link(tiler)\n", "# Otherwise, linke pgie > tiler\n", "else:\n", " pgie.link(tiler)\n", @@ -1125,22 +1119,13 @@ " if not sgie2:\n", " sys.stderr.write(\" Unable to make sgie2 \\n\")\n", "\n", - " print(\"Creating nvinfer (SGIE3) \\n \")\n", - "\n", - " # Create nvinfer element\n", - " sgie3 = Gst.ElementFactory.make(\"nvinfer\", \"secondary3-nvinference-engine\")\n", - " if not sgie3:\n", - " sys.stderr.write(\" Unable to make sgie3 \\n\")\n", - "\n", " # Set config file for each SGIE\n", " sgie1.set_property('config-file-path', sgie1_config_file)\n", " sgie2.set_property('config-file-path', sgie2_config_file)\n", - " sgie3.set_property('config-file-path', sgie3_config_file)\n", "\n", " # Add SGIEs to pipeline\n", " pipeline.add(sgie1)\n", " pipeline.add(sgie2)\n", - " pipeline.add(sgie3)\n", " \n", " print(\"Creating tiler \\n \")\n", "\n", @@ -1234,13 +1219,12 @@ " # Note that the sources were already linked to the streammux\n", " # Link streammux > pgie\n", " streammux.link(pgie)\n", - " # If tracker is enabled, link pgie > tracker > sgie1 > sgie2 > sgie3 > tiler\n", + " # If tracker is enabled, link pgie > tracker > sgie1 > sgie2 > tiler\n", " if enable_tracker:\n", " pgie.link(tracker)\n", " tracker.link(sgie1)\n", " sgie1.link(sgie2)\n", - " sgie2.link(sgie3)\n", - " sgie3.link(tiler)\n", + " sgie2.link(tiler)\n", " # Otherwise, linke pgie > tiler\n", " else:\n", " pgie.link(tiler)\n", @@ -1614,7 +1598,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3.9.5 64-bit", "language": "python", "name": "python3" }, @@ -1628,7 +1612,12 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.9.5" + }, + "vscode": { + "interpreter": { + "hash": "f9f85f796d01129d0dd105a088854619f454435301f6ffec2fea96ecbd9be4ac" + } } }, "nbformat": 4, diff --git a/notebooks/deepstream_test_1.ipynb b/notebooks/deepstream_test_1.ipynb index 1d935df..0ce5d67 100644 --- a/notebooks/deepstream_test_1.ipynb +++ b/notebooks/deepstream_test_1.ipynb @@ -50,9 +50,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - " * **DeepStream SDK 6.3**\n", + " * **DeepStream SDK 6.4**\n", "\n", - "To setup and install DeepStream 6.3, please follow the steps at https://developer.nvidia.com/deepstream-getting-started\n", + "To setup and install DeepStream 6.4, please follow the steps at https://developer.nvidia.com/deepstream-getting-started\n", " \n", " * **DeepStream Python Apps**\n", "\n", @@ -598,7 +598,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3.8.10 64-bit", + "display_name": "Python 3.9.5 64-bit", "language": "python", "name": "python3" }, @@ -612,11 +612,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.9.5" }, "vscode": { "interpreter": { - "hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a" + "hash": "f9f85f796d01129d0dd105a088854619f454435301f6ffec2fea96ecbd9be4ac" } } }, diff --git a/notebooks/deepstream_test_4.ipynb b/notebooks/deepstream_test_4.ipynb index ed0d6e1..6bc9587 100644 --- a/notebooks/deepstream_test_4.ipynb +++ b/notebooks/deepstream_test_4.ipynb @@ -11,7 +11,9 @@ "* Use \"nvmsgconv\" and \"nvmsgbroker\" plugins in the pipeline.\n", "* Create NVDS_META_EVENT_MSG type of meta and attach to buffer.\n", "* Use NVDS_META_EVENT_MSG for different types of objects e.g. vehicle, person etc.\n", - "* Provide copy / free functions if meta data is extended through \"extMsg\" field.\n", + "* copy / free functions if meta data is extended through \"extMsg\" field have been moved out of the deepstream_test4 python app.\n", + "These copy and free functions are available for using/extending inside bindschema.cpp as event_msg_meta_copy_func() and\n", + "event_msg_meta_release_func() respectively.\n", "\n", "\"nvmsgconv\" plugin uses NVDS_META_EVENT_MSG type of metadata from the buffer\n", "and generates the \"DeepStream Schema\" payload in Json format. Static properties\n", @@ -29,7 +31,7 @@ "create custom structure, fill that structure and assign the pointer of that\n", "structure as \"extMsg\" and set the \"extMsgSize\" accordingly.\n", "If custom object contains fields that can't be simply mem copied then user should\n", - "also provide function to copy and free those objects." + "also provide/extend the functions to copy - event_msg_meta_copy_func() and free - event_msg_meta_release_func() those objects." ] }, { @@ -43,9 +45,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - " * **DeepStream SDK 6.3**\n", + " * **DeepStream SDK 6.4**\n", "\n", - "To setup and install DeepStream 6.3, please follow the steps at https://developer.nvidia.com/deepstream-getting-started\n", + "To setup and install DeepStream 6.4, please follow the steps at https://developer.nvidia.com/deepstream-getting-started\n", " \n", " * **DeepStream Python Apps**\n", "\n", @@ -67,9 +69,9 @@ " SSL suport enabled by using the enable_ssl option while running\n", " 'configure', as shown below. Also note that these are the same steps as setup in [Deepstream Quickstart Guide](https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Quickstart.html#id1). If already previously completed, please skip this step. \n", "```\n", - " git clone https://github.com/edenhill/librdkafka.git\n", + " git clone https://github.com/confluentinc/librdkafka.git\n", " cd librdkafka\n", - " git reset --hard 063a9ae7a65cebdf1cc128da9815c05f91a2a996\n", + " git checkout tags/v2.2.0\n", " ./configure --enable-ssl\n", " make\n", " sudo make install\n", @@ -192,7 +194,7 @@ "PGIE_CLASS_ID_ROADSIGN = 3\n", "MUXER_OUTPUT_WIDTH = 1920\n", "MUXER_OUTPUT_HEIGHT = 1080\n", - "MUXER_BATCH_TIMEOUT_USEC = 4000000\n", + "MUXER_BATCH_TIMEOUT_USEC = 33000\n", "cfg_file = \"../apps/deepstream-test4/cfg_kafka.txt\"\n", "input_file = \"/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.h264\"\n", "proto_lib = \"/opt/nvidia/deepstream/deepstream/lib/libnvds_kafka_proto.so\"\n", @@ -220,122 +222,6 @@ "pgie_classes_str = [\"Vehicle\", \"TwoWheeler\", \"Person\", \"Roadsign\"]" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Callback function for deep-copying an NvDsEventMsgMeta struct" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def meta_copy_func(data, user_data):\n", - " # Cast data to pyds.NvDsUserMeta\n", - " user_meta = pyds.NvDsUserMeta.cast(data)\n", - " src_meta_data = user_meta.user_meta_data\n", - " # Cast src_meta_data to pyds.NvDsEventMsgMeta\n", - " srcmeta = pyds.NvDsEventMsgMeta.cast(src_meta_data)\n", - " # Duplicate the memory contents of srcmeta to dstmeta\n", - " # First use pyds.get_ptr() to get the C address of srcmeta, then\n", - " # use pyds.memdup() to allocate dstmeta and copy srcmeta into it.\n", - " # pyds.memdup returns C address of the allocated duplicate.\n", - " dstmeta_ptr = pyds.memdup(pyds.get_ptr(srcmeta),\n", - " sys.getsizeof(pyds.NvDsEventMsgMeta))\n", - " # Cast the duplicated memory to pyds.NvDsEventMsgMeta\n", - " dstmeta = pyds.NvDsEventMsgMeta.cast(dstmeta_ptr)\n", - "\n", - " # Duplicate contents of ts field. Note that reading srcmeat.ts\n", - " # returns its C address. This allows to memory operations to be\n", - " # performed on it.\n", - " dstmeta.ts = pyds.memdup(srcmeta.ts, MAX_TIME_STAMP_LEN + 1)\n", - "\n", - " # Copy the sensorStr. This field is a string property. The getter (read)\n", - " # returns its C address. The setter (write) takes string as input,\n", - " # allocates a string buffer and copies the input string into it.\n", - " # pyds.get_string() takes C address of a string and returns the reference\n", - " # to a string object and the assignment inside the binder copies content.\n", - " dstmeta.sensorStr = pyds.get_string(srcmeta.sensorStr)\n", - "\n", - " if srcmeta.objSignature.size > 0:\n", - " dstmeta.objSignature.signature = pyds.memdup(\n", - " srcmeta.objSignature.signature, srcmeta.objSignature.size)\n", - " dstmeta.objSignature.size = srcmeta.objSignature.size\n", - "\n", - " if srcmeta.extMsgSize > 0:\n", - " if srcmeta.objType == pyds.NvDsObjectType.NVDS_OBJECT_TYPE_VEHICLE:\n", - " srcobj = pyds.NvDsVehicleObject.cast(srcmeta.extMsg)\n", - " obj = pyds.alloc_nvds_vehicle_object()\n", - " obj.type = pyds.get_string(srcobj.type)\n", - " obj.make = pyds.get_string(srcobj.make)\n", - " obj.model = pyds.get_string(srcobj.model)\n", - " obj.color = pyds.get_string(srcobj.color)\n", - " obj.license = pyds.get_string(srcobj.license)\n", - " obj.region = pyds.get_string(srcobj.region)\n", - " dstmeta.extMsg = obj\n", - " dstmeta.extMsgSize = sys.getsizeof(pyds.NvDsVehicleObject)\n", - " if srcmeta.objType == pyds.NvDsObjectType.NVDS_OBJECT_TYPE_PERSON:\n", - " srcobj = pyds.NvDsPersonObject.cast(srcmeta.extMsg)\n", - " obj = pyds.alloc_nvds_person_object()\n", - " obj.age = srcobj.age\n", - " obj.gender = pyds.get_string(srcobj.gender)\n", - " obj.cap = pyds.get_string(srcobj.cap)\n", - " obj.hair = pyds.get_string(srcobj.hair)\n", - " obj.apparel = pyds.get_string(srcobj.apparel)\n", - " dstmeta.extMsg = obj\n", - " dstmeta.extMsgSize = sys.getsizeof(pyds.NvDsVehicleObject)\n", - "\n", - " return dstmeta" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Callback function for freeing an NvDsEventMsgMeta instance" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def meta_free_func(data, user_data):\n", - " user_meta = pyds.NvDsUserMeta.cast(data)\n", - " srcmeta = pyds.NvDsEventMsgMeta.cast(user_meta.user_meta_data)\n", - "\n", - " # pyds.free_buffer takes C address of a buffer and frees the memory\n", - " # It's a NOP if the address is NULL\n", - " pyds.free_buffer(srcmeta.ts)\n", - " pyds.free_buffer(srcmeta.sensorStr)\n", - "\n", - " if srcmeta.objSignature.size > 0:\n", - " pyds.free_buffer(srcmeta.objSignature.signature)\n", - " srcmeta.objSignature.size = 0\n", - "\n", - " if srcmeta.extMsgSize > 0:\n", - " if srcmeta.objType == pyds.NvDsObjectType.NVDS_OBJECT_TYPE_VEHICLE:\n", - " obj = pyds.NvDsVehicleObject.cast(srcmeta.extMsg)\n", - " pyds.free_buffer(obj.type)\n", - " pyds.free_buffer(obj.color)\n", - " pyds.free_buffer(obj.make)\n", - " pyds.free_buffer(obj.model)\n", - " pyds.free_buffer(obj.license)\n", - " pyds.free_buffer(obj.region)\n", - " if srcmeta.objType == pyds.NvDsObjectType.NVDS_OBJECT_TYPE_PERSON:\n", - " obj = pyds.NvDsPersonObject.cast(srcmeta.extMsg)\n", - " pyds.free_buffer(obj.gender)\n", - " pyds.free_buffer(obj.cap)\n", - " pyds.free_buffer(obj.hair)\n", - " pyds.free_buffer(obj.apparel)\n", - " pyds.free_gbuffer(srcmeta.extMsg)\n", - " srcmeta.extMsgSize = 0" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -518,29 +404,26 @@ " # Frequency of messages to be send will be based on use case.\n", " # Here message is being sent for first object every 30 frames.\n", "\n", - " # Allocating an NvDsEventMsgMeta instance and getting\n", - " # reference to it. The underlying memory is not manged by\n", - " # Python so that downstream plugins can access it. Otherwise\n", - " # the garbage collector will free it when this probe exits.\n", - " msg_meta = pyds.alloc_nvds_event_msg_meta()\n", - " msg_meta.bbox.top = obj_meta.rect_params.top\n", - " msg_meta.bbox.left = obj_meta.rect_params.left\n", - " msg_meta.bbox.width = obj_meta.rect_params.width\n", - " msg_meta.bbox.height = obj_meta.rect_params.height\n", - " msg_meta.frameId = frame_number\n", - " msg_meta.trackingId = long_to_uint64(obj_meta.object_id)\n", - " msg_meta.confidence = obj_meta.confidence\n", - " msg_meta = generate_event_msg_meta(msg_meta, obj_meta.class_id)\n", " user_event_meta = pyds.nvds_acquire_user_meta_from_pool(\n", " batch_meta)\n", " if user_event_meta:\n", + " # Allocating an NvDsEventMsgMeta instance and getting\n", + " # reference to it. The underlying memory is not manged by\n", + " # Python so that downstream plugins can access it. Otherwise\n", + " # the garbage collector will free it when this probe exits.\n", + " msg_meta = pyds.alloc_nvds_event_msg_meta(user_event_meta)\n", + " msg_meta.bbox.top = obj_meta.rect_params.top\n", + " msg_meta.bbox.left = obj_meta.rect_params.left\n", + " msg_meta.bbox.width = obj_meta.rect_params.width\n", + " msg_meta.bbox.height = obj_meta.rect_params.height\n", + " msg_meta.frameId = frame_number\n", + " msg_meta.trackingId = long_to_uint64(obj_meta.object_id)\n", + " msg_meta.confidence = obj_meta.confidence\n", + " msg_meta = generate_event_msg_meta(msg_meta, obj_meta.class_id)\n", + "\n", " user_event_meta.user_meta_data = msg_meta\n", " user_event_meta.base_meta.meta_type = pyds.NvDsMetaType.NVDS_EVENT_MSG_META\n", - " # Setting callbacks in the event msg meta. The bindings\n", - " # layer will wrap these callables in C functions.\n", - " # Currently only one set of callbacks is supported.\n", - " pyds.user_copyfunc(user_event_meta, meta_copy_func)\n", - " pyds.user_releasefunc(user_event_meta, meta_free_func)\n", + "\n", " pyds.nvds_add_user_meta_to_frame(frame_meta,\n", " user_event_meta)\n", " else:\n", @@ -577,9 +460,14 @@ "source": [ "Gst.init(None)\n", "\n", - "# registering callbacks\n", - "pyds.register_user_copyfunc(meta_copy_func)\n", - "pyds.register_user_releasefunc(meta_free_func)\n", + "# Deprecated: following meta_copy_func and meta_free_func\n", + "# have been moved to the binding as event_msg_meta_copy_func()\n", + "# and event_msg_meta_release_func() respectively.\n", + "# Hence, registering and unsetting these callbacks in not needed\n", + "# anymore. Please extend the above functions as necessary instead.\n", + "# # registering callbacks\n", + "# pyds.register_user_copyfunc(meta_copy_func)\n", + "# pyds.register_user_releasefunc(meta_free_func)\n", "\n", "print(\"Creating Pipeline \\n \")\n", "\n", @@ -859,7 +747,7 @@ "streammux.set_property('width', 1920)\n", "streammux.set_property('height', 1080)\n", "streammux.set_property('batch-size', 1)\n", - "streammux.set_property('batched-push-timeout', 4000000)\n", + "streammux.set_property('batched-push-timeout', 33000)\n", "pgie.set_property('config-file-path', PGIE_CONFIG_FILE)\n", "msgconv.set_property('config', MSCONV_CONFIG_FILE)\n", "msgconv.set_property('payload-type', schema_type)\n", @@ -1006,14 +894,13 @@ "metadata": {}, "outputs": [], "source": [ - "pyds.unset_callback_funcs()\n", "pipeline.set_state(Gst.State.NULL)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3.8.10 64-bit", + "display_name": "Python 3.9.5 64-bit", "language": "python", "name": "python3" }, @@ -1027,11 +914,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.10" + "version": "3.9.5" }, "vscode": { "interpreter": { - "hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a" + "hash": "f9f85f796d01129d0dd105a088854619f454435301f6ffec2fea96ecbd9be4ac" } } }, diff --git a/tests/__pycache__/__init__.cpython-310.pyc b/tests/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..a82ef58 Binary files /dev/null and b/tests/__pycache__/__init__.cpython-310.pyc differ diff --git a/tests/common/__pycache__/__init__.cpython-310.pyc b/tests/common/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..44204c3 Binary files /dev/null and b/tests/common/__pycache__/__init__.cpython-310.pyc differ diff --git a/tests/common/__pycache__/frame_iterator.cpython-310.pyc b/tests/common/__pycache__/frame_iterator.cpython-310.pyc new file mode 100644 index 0000000..d3582f7 Binary files /dev/null and b/tests/common/__pycache__/frame_iterator.cpython-310.pyc differ diff --git a/tests/common/__pycache__/generic_pipeline.cpython-310.pyc b/tests/common/__pycache__/generic_pipeline.cpython-310.pyc new file mode 100644 index 0000000..7dd8907 Binary files /dev/null and b/tests/common/__pycache__/generic_pipeline.cpython-310.pyc differ diff --git a/tests/common/__pycache__/pipeline_fakesink.cpython-310.pyc b/tests/common/__pycache__/pipeline_fakesink.cpython-310.pyc new file mode 100644 index 0000000..30e03a7 Binary files /dev/null and b/tests/common/__pycache__/pipeline_fakesink.cpython-310.pyc differ diff --git a/tests/common/__pycache__/pipeline_fakesink_tracker.cpython-310.pyc b/tests/common/__pycache__/pipeline_fakesink_tracker.cpython-310.pyc new file mode 100644 index 0000000..2034094 Binary files /dev/null and b/tests/common/__pycache__/pipeline_fakesink_tracker.cpython-310.pyc differ diff --git a/tests/common/__pycache__/tracker_utils.cpython-310.pyc b/tests/common/__pycache__/tracker_utils.cpython-310.pyc new file mode 100644 index 0000000..f1ea97d Binary files /dev/null and b/tests/common/__pycache__/tracker_utils.cpython-310.pyc differ diff --git a/tests/common/__pycache__/utils.cpython-310.pyc b/tests/common/__pycache__/utils.cpython-310.pyc new file mode 100644 index 0000000..fd4bb6f Binary files /dev/null and b/tests/common/__pycache__/utils.cpython-310.pyc differ diff --git a/tests/common/pipeline_fakesink_tracker.py b/tests/common/pipeline_fakesink_tracker.py index f62e6fe..38d10aa 100644 --- a/tests/common/pipeline_fakesink_tracker.py +++ b/tests/common/pipeline_fakesink_tracker.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -37,7 +37,6 @@ def __init__(self, properties, is_aarch64): ["nvtracker", "tracker"], # tracker ["nvinfer", "secondary1-nvinference-engine"], # sgie1 ["nvinfer", "secondary2-nvinference-engine"], # sgie2 - ["nvinfer", "secondary3-nvinference-engine"], # sgie3 ["nvvideoconvert", "convertor"], # nvvidconv ["nvdsosd", "onscreendisplay"], # nvosd ["fakesink", "fakesink"], # sink @@ -65,7 +64,6 @@ def _link_elements(self): tracker = gebn("tracker") sgie1 = gebn("secondary1-nvinference-engine") sgie2 = gebn("secondary2-nvinference-engine") - sgie3 = gebn("secondary3-nvinference-engine") nvvidconv = gebn("convertor") nvosd = gebn("onscreendisplay") sink = gebn("fakesink") @@ -88,8 +86,7 @@ def _link_elements(self): pgie.link(tracker) tracker.link(sgie1) sgie1.link(sgie2) - sgie2.link(sgie3) - sgie3.link(nvvidconv) + sgie2.link(nvvidconv) nvvidconv.link(nvosd) nvosd.link(sink) return True diff --git a/tests/integration/README.md b/tests/integration/README.md index 4c62e1a..9f38d2e 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -40,22 +40,16 @@ mkdir -p bindings/build cd bindings/build ``` ### step2 -#### Python 3.6 +#### Python 3.10 ``` -cmake .. -DPYTHON_MINOR_VERSION=6 +cmake .. -DPYTHON_MINOR_VERSION=10 make -python3.6 -m venv env -``` -#### Python 3.8 -``` -cmake .. -DPYTHON_MINOR_VERSION=8 -make -python3.8 -m venv env +python3.10 -m venv env ``` ### step3 ``` . env/bin/activate -pip install pyds-1.1.8-py3-none-*.whl +pip install pyds-1.1.10-py3-none-*.whl pip install pytest cd ../../tests/integration pytest test.py diff --git a/tests/integration/__pycache__/__init__.cpython-310.pyc b/tests/integration/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..c294419 Binary files /dev/null and b/tests/integration/__pycache__/__init__.cpython-310.pyc differ diff --git a/tests/integration/__pycache__/test.cpython-310-pytest-7.4.2.pyc b/tests/integration/__pycache__/test.cpython-310-pytest-7.4.2.pyc new file mode 100644 index 0000000..c6d228e Binary files /dev/null and b/tests/integration/__pycache__/test.cpython-310-pytest-7.4.2.pyc differ diff --git a/tests/integration/ds_base_config.txt b/tests/integration/ds_base_config.txt index c383a56..a0e4e0f 100644 --- a/tests/integration/ds_base_config.txt +++ b/tests/integration/ds_base_config.txt @@ -1,4 +1,5 @@ -# SPDX-FileCopyrightText: Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +################################################################################ +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,6 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +################################################################################ # Following properties are mandatory when engine files are not specified: # int8-calib-file(Only in INT8) @@ -52,21 +54,28 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 +batch-size=30 +process-mode=1 +model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 diff --git a/tests/integration/ds_pgie_config.txt b/tests/integration/ds_pgie_config.txt index d2f72fd..a0e4e0f 100644 --- a/tests/integration/ds_pgie_config.txt +++ b/tests/integration/ds_pgie_config.txt @@ -1,4 +1,5 @@ -# SPDX-FileCopyrightText: Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +################################################################################ +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,6 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +################################################################################ # Following properties are mandatory when engine files are not specified: # int8-calib-file(Only in INT8) @@ -52,23 +54,28 @@ [property] gpu-id=0 -net-scale-factor=0.0039215697906911373 -model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel -proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt -model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine +net-scale-factor=0.00392156862745098 +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin force-implicit-batch-dim=1 -batch-size=1 -network-mode=1 +batch-size=30 process-mode=1 model-color-format=0 +## 0=FP32, 1=INT8, 2=FP16 mode +network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid +uff-input-order=0 +uff-input-blob-name=input_1 +output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 +cluster-mode=2 +infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 diff --git a/tests/integration/ds_sgie1_config.txt b/tests/integration/ds_sgie1_config.txt index 424e57e..d8f02d4 100644 --- a/tests/integration/ds_sgie1_config.txt +++ b/tests/integration/ds_sgie1_config.txt @@ -1,4 +1,5 @@ -# SPDX-FileCopyrightText: Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +################################################################################ +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,6 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +################################################################################ # Following properties are mandatory when engine files are not specified: # int8-calib-file(Only in INT8) @@ -53,12 +55,11 @@ [property] gpu-id=0 net-scale-factor=1 -model-file=../../../../samples/models/Secondary_CarColor/resnet18.caffemodel -proto-file=../../../../samples/models/Secondary_CarColor/resnet18.prototxt -model-engine-file=../../../../samples/models/Secondary_CarColor/resnet18.caffemodel_b16_gpu0_int8.engine -mean-file=../../../../samples/models/Secondary_CarColor/mean.ppm -labelfile-path=../../../../samples/models/Secondary_CarColor/labels.txt -int8-calib-file=../../../../samples/models/Secondary_CarColor/cal_trt.bin +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt +model-engine-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt_b16_gpu0_int8.engine +labelfile-path=../../../../samples/models/Secondary_VehicleMake/labels.txt +int8-calib-file=../../../../samples/models/Secondary_VehicleMake/cal_trt.bin force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode @@ -72,9 +73,11 @@ gie-unique-id=2 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 +uff-input-blob-name=input_1 output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 #scaling-compute-hw=0 +infer-dims=3;244;244 \ No newline at end of file diff --git a/tests/integration/ds_sgie2_config.txt b/tests/integration/ds_sgie2_config.txt index e421c4b..8b0313b 100644 --- a/tests/integration/ds_sgie2_config.txt +++ b/tests/integration/ds_sgie2_config.txt @@ -1,4 +1,5 @@ -# SPDX-FileCopyrightText: Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +################################################################################ +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,6 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +################################################################################ # Following properties are mandatory when engine files are not specified: # int8-calib-file(Only in INT8) @@ -53,12 +55,11 @@ [property] gpu-id=0 net-scale-factor=1 -model-file=../../../../samples/models/Secondary_CarMake/resnet18.caffemodel -proto-file=../../../../samples/models/Secondary_CarMake/resnet18.prototxt -model-engine-file=../../../../samples/models/Secondary_CarMake/resnet18.caffemodel_b16_gpu0_int8.engine -mean-file=../../../../samples/models/Secondary_CarMake/mean.ppm -labelfile-path=../../../../samples/models/Secondary_CarMake/labels.txt -int8-calib-file=../../../../samples/models/Secondary_CarMake/cal_trt.bin +tlt-model-key=tlt_encode +tlt-encoded-model=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt +model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt_b16_gpu0_int8.engine +labelfile-path=../../../../samples/models/Secondary_VehicleTypes/labels.txt +int8-calib-file=../../../../samples/models/Secondary_VehicleTypes/cal_trt.bin force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode @@ -72,9 +73,11 @@ gie-unique-id=3 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 +uff-input-blob-name=input_1 output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 #scaling-compute-hw=0 +infer-dims=3;244;244 diff --git a/tests/integration/ds_sgie3_config.txt b/tests/integration/ds_sgie3_config.txt deleted file mode 100644 index 076d1aa..0000000 --- a/tests/integration/ds_sgie3_config.txt +++ /dev/null @@ -1,80 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Following properties are mandatory when engine files are not specified: -# int8-calib-file(Only in INT8) -# Caffemodel mandatory properties: model-file, proto-file, output-blob-names -# UFF: uff-file, input-dims, uff-input-blob-name, output-blob-names -# ONNX: onnx-file -# -# Mandatory properties for detectors: -# num-detected-classes -# -# Optional properties for detectors: -# cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0) -# custom-lib-path, -# parse-bbox-func-name -# -# Mandatory properties for classifiers: -# classifier-threshold, is-classifier -# -# Optional properties for classifiers: -# classifier-async-mode(Secondary mode only, Default=false) -# -# Optional properties in secondary mode: -# operate-on-gie-id(Default=0), operate-on-class-ids(Defaults to all classes), -# input-object-min-width, input-object-min-height, input-object-max-width, -# input-object-max-height -# -# Following properties are always recommended: -# batch-size(Default=1) -# -# Other optional properties: -# net-scale-factor(Default=1), network-mode(Default=0 i.e FP32), -# model-color-format(Default=0 i.e. RGB) model-engine-file, labelfile-path, -# mean-file, gie-unique-id(Default=0), offsets, process-mode (Default=1 i.e. primary), -# custom-lib-path, network-mode(Default=0 i.e FP32) -# -# The values in the config file are overridden by values set through GObject -# properties. - -[property] -gpu-id=0 -net-scale-factor=1 -model-file=../../../../samples/models/Secondary_VehicleTypes/resnet18.caffemodel -proto-file=../../../../samples/models/Secondary_VehicleTypes/resnet18.prototxt -model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18.caffemodel_b16_gpu0_int8.engine -mean-file=../../../../samples/models/Secondary_VehicleTypes/mean.ppm -labelfile-path=../../../../samples/models/Secondary_VehicleTypes/labels.txt -int8-calib-file=../../../../samples/models/Secondary_VehicleTypes/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=16 -# 0=FP32 and 1=INT8 mode -network-mode=1 -input-object-min-width=64 -input-object-min-height=64 -model-color-format=1 -process-mode=2 -gpu-id=0 -gie-unique-id=4 -operate-on-gie-id=1 -operate-on-class-ids=0 -is-classifier=1 -output-blob-names=predictions/Softmax -classifier-async-mode=1 -classifier-threshold=0.51 -process-mode=2 -#scaling-filter=0 -#scaling-compute-hw=0 diff --git a/tests/integration/test.py b/tests/integration/test.py index f8b9c89..27ccc2c 100644 --- a/tests/integration/test.py +++ b/tests/integration/test.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -57,9 +57,6 @@ }, "secondary2-nvinference-engine": { "config-file-path", "ds_sgie2_config.txt" - }, - "secondary3-nvinference-engine": { - "config-file-path", "ds_sgie3_config.txt" } } STANDARD_CLASS_ID1 = { @@ -138,24 +135,24 @@ def user_function(batch_meta, user_meta, dict_data): return if not user_meta.base_meta.meta_type == pyds.NvDsMetaType.NVDS_TRACKER_PAST_FRAME_META: return - pPastFrameObjBatch = pyds.NvDsPastFrameObjBatch.cast(user_meta.user_meta_data) + miscDataBatch = pyds.NvDsTargetMiscDataBatch.cast(user_meta.user_meta_data) tracker_data = dict_data["tracker_data"] - for trackobj in pyds.NvDsPastFrameObjBatch.list(pPastFrameObjBatch): - tracker_data["stream_id"].add(trackobj.streamID) - tracker_data["surface_stream_id"].add(trackobj.surfaceStreamID) - for pastframeobj in pyds.NvDsPastFrameObjStream.list(trackobj): - tracker_data["numobj"].add(pastframeobj.numObj) - tracker_data["unique_id"].add(pastframeobj.uniqueId) - tracker_data["class_id"].add(pastframeobj.classId) - tracker_data["obj_label"].add(pastframeobj.objLabel) - for objlist in pyds.NvDsPastFrameObjList.list(pastframeobj): - tracker_data["frame_num"].add(objlist.frameNum) - tracker_data["tbox_left"].add(objlist.tBbox.left) - tracker_data["tbox_width"].add(objlist.tBbox.width) - tracker_data["tbox_top"].add(objlist.tBbox.top) - tracker_data["tbox_right"].add(objlist.tBbox.height) - tracker_data["confidence"].add(objlist.confidence) - tracker_data["age"].add(objlist.confidence) + for miscDataStream in pyds.NvDsTargetMiscDataBatch.list(miscDataBatch): + tracker_data["stream_id"].add(miscDataStream.streamID) + tracker_data["surface_stream_id"].add(miscDataStream.surfaceStreamID) + for miscDataObj in pyds.NvDsTargetMiscDataStream.list(miscDataStream): + tracker_data["numobj"].add(miscDataObj.numObj) + tracker_data["unique_id"].add(miscDataObj.uniqueId) + tracker_data["class_id"].add(miscDataObj.classId) + tracker_data["obj_label"].add(miscDataObj.objLabel) + for miscDataFrame in pyds.NvDsTargetMiscDataObject.list(miscDataObj): + tracker_data["frame_num"].add(miscDataFrame.frameNum) + tracker_data["tbox_left"].add(miscDataFrame.tBbox.left) + tracker_data["tbox_width"].add(miscDataFrame.tBbox.width) + tracker_data["tbox_top"].add(miscDataFrame.tBbox.top) + tracker_data["tbox_right"].add(miscDataFrame.tBbox.height) + tracker_data["confidence"].add(miscDataFrame.confidence) + tracker_data["age"].add(miscDataFrame.confidence) # defining the function to be called at each object def box_function(batch_meta, frame_meta, obj_meta, dict_data): @@ -183,9 +180,6 @@ def box_function(batch_meta, frame_meta, obj_meta, dict_data): "secondary2-nvinference-engine": { "config-file-path": "ds_sgie2_config.txt" }, - "secondary3-nvinference-engine": { - "config-file-path": "ds_sgie3_config.txt" - }, "tracker": tracker_cfg } print(properties)