diff --git a/HOWTO.md b/HOWTO.md
index f50f886..5ccf2a8 100644
--- a/HOWTO.md
+++ b/HOWTO.md
@@ -35,10 +35,11 @@ If missing, install with the following steps:
$ sudo make install
```
-
-## Compiling Python Bindings
+
+## Python Bindings Usage
-Please follow instructions for compiling the bindings [here](bindings/README.md)
+The prebuilt DeepStreamSDK python bindings for both x86 and Jetson are already available on the [release section](../../releases).
+The readme [here](bindings/README.md) provides instructions to customize the bindings or recompile them, if you need to.
Note: Compiling bindings now also generates a pip installable python wheel for the platform (x86 or aarch64) it is compiled on.
diff --git a/apps/deepstream-preprocess-test/README b/apps/deepstream-preprocess-test/README
index 9c22fa6..425a372 100644
--- a/apps/deepstream-preprocess-test/README
+++ b/apps/deepstream-preprocess-test/README
@@ -19,12 +19,25 @@ Prerequisites:
- DeepStreamSDK 6.1
- Python 3.8
- Gst-python
+- GstRtspServer
+
+Installing GstRtspServer and introspection typelib
+===================================================
+$ sudo apt update
+$ sudo apt install python3-gi python3-dev python3-gst-1.0 -y
+$ sudo apt-get install libgstrtspserver-1.0-0 gstreamer1.0-rtsp
+For gst-rtsp-server (and other GStreamer stuff) to be accessible in
+Python through gi.require_version(), it needs to be built with
+gobject-introspection enabled (libgstrtspserver-1.0-0 is already).
+Yet, we need to install the introspection typelib package:
+$ sudo apt-get install libgirepository1.0-dev
+$ sudo apt-get install gobject-introspection gir1.2-gst-rtsp-server-1.0
To run:
- $ python3 deepstream_preprocess-test.py -i [uri2] ... [uriN]
+ $ python3 deepstream_preprocess_test.py -i [uri2] ... [uriN] [-c {H264,H265}] [-b BITRATE]
e.g.
- $ python3 deepstream_preprocess-test.py -i file:///home/ubuntu/video1.mp4 file:///home/ubuntu/video2.mp4
- $ python3 deepstream_preprocess-test.py -i rtsp://127.0.0.1/video1 rtsp://127.0.0.1/video2
+ $ python3 deepstream_preprocess_test.py -i file:///home/ubuntu/video1.mp4 file:///home/ubuntu/video2.mp4
+ $ python3 deepstream_preprocess_test.py -i rtsp://127.0.0.1/video1 rtsp://127.0.0.1/video2
This document describes the sample deepstream_preprocess-test application
diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt
index 089cc22..ab366d5 100644
--- a/bindings/CMakeLists.txt
+++ b/bindings/CMakeLists.txt
@@ -50,7 +50,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.2-py3-none-${PIP_PLATFORM}.whl)
+set(PIP_WHEEL pyds-1.1.3-py3-none-${PIP_PLATFORM}.whl)
# Describing pyds build
project(pyds DESCRIPTION "Python bindings for Deepstream")
@@ -99,7 +99,7 @@ function(add_ds_lib libname)
target_link_libraries(pyds ${libname})
endfunction()
-foreach(nvds_lib nvds_osd nvds_meta nvds_infer nvdsgst_meta nvbufsurface nvbufsurftransform)
+foreach(nvds_lib nvds_osd nvds_meta nvds_infer nvdsgst_meta nvbufsurface nvbufsurftransform nvdsgst_helper)
add_ds_lib(${nvds_lib})
endforeach()
diff --git a/bindings/README.md b/bindings/README.md
index 34fb9d7..199e497 100644
--- a/bindings/README.md
+++ b/bindings/README.md
@@ -1,53 +1,102 @@
-# Deepstream python bindings
-
-## 1 - Purpose
-
-This file describes how to compile and install deepstream python bindings
-
-## 2 - Prerequisites
-
-The following dependencies need to be met:
+# DeepStream python bindings
+
+SDK version supported: 6.1
+
+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.
+
+This readme describes how to compile and install DeepStream python bindings (henceforth referred as bindings). This process is mainly useful for making customizations in the bindings and compiling it yourself instead of using the prebuilt versions provided in the release section.
+
+The readme is divided into three main parts:
+- [DeepStream python bindings](#deepstream-python-bindings)
+ - [1 - Prerequisites](#1-prerequisites)
+ - [1.1 - Deepstream SDK](#11-deepstream-sdk)
+ - [1.2 Base dependencies](#12-base-dependencies)
+ - [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-18.04 | python 3.6 | Deepstream 6.0.1)](#21-quick-build-x86-ubuntu-1804--python-36--deepstream-601)
+ - [2.1.1 Quick build (x86-ubuntu-20.04 | python 3.8 | Deepstream 6.1)](#211-quick-build-x86-ubuntu-2004--python-38--deepstream-61)
+ - [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.0.1 DP](#232-download-the-jetpack-sdk-501-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)
+ - [3 - Installing the bindings](#3-installing-the-bindings)
+ - [3.1 Installing the pip wheel](#31-installing-the-pip-wheel)
+ - [3.1.1 pip wheel troubleshooting](#311-pip-wheel-troubleshooting)
+ - [3.2 Launching test-1 app](#32-launching-test-1-app)
+
+
+## 1 - Prerequisites
+
+The following dependencies need to be met in order to compile bindings:
+
+
+### 1.1 - Deepstream SDK
+Go to https://developer.nvidia.com/deepstream-sdk, download and install Deepstream SDK and its dependencies
-### 2.1 Base dependencies
-Ubuntu - 18.04 :
+
+### 1.2 Base dependencies
+To compile bindings on Ubuntu - 18.04 :
```
apt install -y git python-dev python3 python3-pip python3.6-dev python3.8-dev cmake g++ build-essential \
- libglib2.0-dev libglib2.0-dev-bin python-gi-dev libtool m4 autoconf automake
+ libglib2.0-dev libglib2.0-dev-bin python-gi-dev libtool m4 autoconf automake libgirepository1.0-dev libcairo2-dev
```
-Ubuntu - 20.04 [use python-3.8, python-3.6 will not work] :
+To compile bindings on Ubuntu - 20.04 [use python-3.8, python-3.6 will not work] :
```
apt install python3-gi python3-dev python3-gst-1.0 python-gi-dev git python-dev \
python3 python3-pip python3.8-dev cmake g++ build-essential libglib2.0-dev \
- libglib2.0-dev-bin python-gi-dev libtool m4 autoconf automake
+ libglib2.0-dev-bin libgstreamer1.0-dev libtool m4 autoconf automake libgirepository1.0-dev libcairo2-dev
```
-### 2.2 Initialization of submodules
+
+### 1.3 Initialization of submodules
+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
+```
+
+The repository utilizes gst-python and pybind11 submodules.
+To initializes them, run the following command:
+```bash
+cd /opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/
git submodule update --init
```
-### 2.3 Installing Gst-python
+
+### 1.4 Installing Gst-python
Following commands ensure we add the new certificates that gst-python git server now uses:
-```
+```bash
sudo apt-get install -y apt-transport-https ca-certificates -y
sudo update-ca-certificates
```
Build and install gst-python:
-```
+```bash
cd 3rdparty/gst-python/
./autogen.sh
make
-make install
+sudo make install
```
-### 2.4 - Deepstream SDK
-Go to https://developer.nvidia.com/deepstream-sdk, download and install Deepstream SDK and its dependencies
-## 3 - Building the bindings
+
+## 2 - Compiling the bindings
+Python bindings are compiled using CMake.
+Following commands provide quick cmake configurations for common compilation options:
-### 3.1 Quick build (x86-ubuntu-18.04 | python 3.6 | Deepstream 6.0.1)
-```
+
+### 2.1 Quick build (x86-ubuntu-18.04 | python 3.6 | Deepstream 6.0.1)
+```bash
cd deepstream_python_apps/bindings
mkdir build
cd build
@@ -55,9 +104,8 @@ cmake .. -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=6
make
```
-### 3.1.1 Quick build (x86-ubuntu-20.04 | python 3.8 | Deepstream 6.1)
-
-```
+### 2.1.1 Quick build (x86-ubuntu-20.04 | python 3.8 | Deepstream 6.1)
+```bash
cd deepstream_python_apps/bindings
mkdir build
cd build
@@ -65,16 +113,16 @@ cmake ..
make
```
+
+### 2.2 Advanced build
-### 3.2 Advanced build
-
-#### 3.2.1 Using Cmake options
+#### 2.2.1 Using Cmake options
-Multiple options can be passed to cmake as follows:
-```
-cmake [-D= [-D= [-D= ... ]]]
+Multiple options can be used with cmake as follows:
+```bash
+cmake .. [-D= [-D= [-D= ... ]]]
```
-#### 3.2.2 Available cmake options
+#### 2.2.2 Available cmake options
| Var | Default value | Purpose | Available values
|-----|:-------------:|---------|:----------------:
@@ -84,11 +132,11 @@ cmake [-D= [-D= [-D= ... ]]]
| 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
-#### 3.2.3 Example
+#### 2.2.3 Example
-Following commands can be used to build the bindings natively on Jetson devices
+Following commands can be used to compile the bindings natively on Jetson devices
-```
+```bash
cd deepstream_python_apps/bindings
mkdir build
cd build
@@ -97,13 +145,14 @@ cmake .. -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=8 \
make
```
-### 3.3 Cross-Compilation for aarch64 on x86
+
+### 2.3 Cross-Compilation for aarch64 on x86
This section outlines how to enable cross-compiling of the DeepStreamSDK python bindings for aarch64 using Docker on x86 host.
NOTE: This will only emulate the CPU, so any calls requiring embedded hardware, such as using CUDA or inference are not supported.
-#### 3.3.1 Build Pre-requisites
+#### 2.3.1 Build Pre-requisites
We use [qemu](https://www.qemu.org/) processor emulator to achieve cross-compilation. Qemu can be installed on the x86 Ubuntu host machine as shown below:
@@ -119,7 +168,10 @@ docker run --rm -t nvcr.io/nvidia/deepstream-l4t:6.1-samples uname -m
#aarch64
```
-#### 3.3.2 Download the JetPack SDK 5.0.1 DP
+#### 2.3.2 Download the JetPack SDK 5.0.1 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.0.1 DP`) and click Continue.
@@ -127,33 +179,38 @@ docker run --rm -t nvcr.io/nvidia/deepstream-l4t:6.1-samples uname -m
5. Go to the download folder, and run:
```bash
-# path/to/deepstream_python_apps is the path where you downloaded the deepstream_python_apps repository
-mkdir -p path/to/deepstream_python_apps/bindings/docker/jetpack_files
-mv ~/Downloads/nvidia/sdkm_downloads/* path/to/deepstream_python_apps/bindings/docker/jetpack_files
+# create directories as follows:
+mkdir -p deepstream_python_apps/bindings/docker/jetpack_files
+# would be /opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/
+# where you downloaded the deepstream_python_apps repository
+mv ~/Downloads/nvidia/sdkm_downloads/* /deepstream_python_apps/bindings/docker/jetpack_files
```
-#### 3.3.3 Generate the cross-compile build container
+#### 2.3.3 Generate the cross-compile build container
Below command generates the build container
```bash
+# cd to bindings dir
+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.1-ubuntu20.04-python-l4t -f qemu_docker/ubuntu-cross-aarch64.Dockerfile .
```
-#### 3.3.4 Launch the cross-compile build container
+#### 2.3.4 Launch the cross-compile build container
```bash
# Create a directory to mount to the container and store your pyds wheel package in
mkdir export_pyds
-# Make sure the tag matches the one from Generate step above
+# Run the container. Make sure the tag matches the one from Generate step above
docker run -it -v $PWD/export_pyds:/export_pyds deepstream-6.1-ubuntu20.04-python-l4t bash
```
-#### 3.3.5 Build DeepStreamSDK python bindings
+#### 2.3.5 Build DeepStreamSDK python bindings
-Inside the cross-compile docker, run following commands:
+After the container launches successfully, while inside the cross-compile docker, run following commands:
```bash
# cd to /opt/nvidia/deepstream/deepstream/sources/ dir
@@ -180,21 +237,27 @@ make -j$(nproc)
cp pyds-*.whl /export_pyds
```
-Build output is generated in the created export_pyds directory (deepstream_python_apps/bindings/export_pyds).
+Build output (pip wheel) is copied to the previously created export_pyds directory (deepstream_python_apps/bindings/export_pyds) on the host machine.
-## 4 - Using the generated pip wheel
+
+## 3 - Installing the bindings
+Following commands can be used to install the generated pip wheel.
-### 4.1 Installing the pip wheel
-```
-apt install libgirepository1.0-dev libcairo2-dev
-pip3 install ./pyds-1.1.2-py3-none*.whl
+
+### 3.1 Installing the pip wheel
+```bash
+pip3 install ./pyds-1.1.3-py3-none*.whl
```
-#### 4.1.1 pip wheel troubleshooting
-Please make sure you upgrade pip if the wheel installation fails
-
-### 4.2 launching test 1 app
+#### 3.1.1 pip wheel troubleshooting
+If the wheel installation fails, upgrade the pip using the following command:
+```bash
+python3 -m pip install --upgrade pip
```
+
+
+### 3.2 Launching test-1 app
+```bash
cd apps/deepstream-test1
python3 deepstream_test_1.py
```
diff --git a/bindings/docstrings/pydocumentation.h b/bindings/docstrings/pydocumentation.h
index 6b23ebb..c0c069e 100644
--- a/bindings/docstrings/pydocumentation.h
+++ b/bindings/docstrings/pydocumentation.h
@@ -2057,6 +2057,14 @@ namespace pydsdoc
:arg index: index of buffer in the batch. -1 for all buffers in batch.
:returns: 0 for success, -1 for failure.)pyds";
+
+ constexpr const char* gst_nvevent_new_stream_reset=R"pyds(
+ Creates a "custom reset" event for the specified source.
+
+ This function can be used to reset the source in case RTSP reconnection
+ is required.
+
+ :arg source_id: source id for which this event needs to be generated.)pyds";
}
namespace nvoptical
diff --git a/bindings/include/pyds.hpp b/bindings/include/pyds.hpp
index 45b1052..3b55862 100644
--- a/bindings/include/pyds.hpp
+++ b/bindings/include/pyds.hpp
@@ -33,6 +33,7 @@
#include "nvdsmeta_schema.h"
#include "nvdsinfer.h"
#include "gstnvdsinfer.h"
+#include "gst-nvevent.h"
#include
#include
diff --git a/bindings/packaging/setup.py b/bindings/packaging/setup.py
index c5cf3a0..512dfe9 100644
--- a/bindings/packaging/setup.py
+++ b/bindings/packaging/setup.py
@@ -17,7 +17,7 @@
setuptools.setup(
name="pyds",
- version="1.1.2",
+ version="1.1.3",
author="NVIDIA",
description="Install precompiled DeepStream Python bindings extension",
url="nvidia.com",
diff --git a/bindings/src/bindfunctions.cpp b/bindings/src/bindfunctions.cpp
index df83c81..0d0e2b8 100644
--- a/bindings/src/bindfunctions.cpp
+++ b/bindings/src/bindfunctions.cpp
@@ -322,9 +322,11 @@ namespace pydeepstream {
}
int channels = 4;
- auto input_surface = inputnvsurface->surfaceList[batchID];
+ /* use const reference here so input_surface is not altered
+ during mapping and syncing for CPU */
+ const NvBufSurfaceParams &input_surface = inputnvsurface->surfaceList[batchID];
#ifdef __aarch64__
- /* Map the buffer if it has not been mapped already, otherwise sync the
+ /* Map the buffer if it has not been mapped already, before syncing the
mapped buffer to CPU.*/
if (nullptr == input_surface.mappedAddr.addr[0]) {
int ret = NvBufSurfaceMap(inputnvsurface, batchID, -1,
@@ -333,9 +335,12 @@ namespace pydeepstream {
cout << "get_nvds_buf_Surface: Failed to map "
<< "buffer to CPU" << endl;
}
- } else {
- NvBufSurfaceSyncForCpu(inputnvsurface, batchID, -1);
}
+ if (NvBufSurfaceSyncForCpu(inputnvsurface, batchID, -1) != 0) {
+ cout << "get_nvds_buf_Surface: Failed to sync "
+ << "buffer to CPU " << endl;
+ }
+
int height = input_surface.height;
int width = input_surface.width;
int pitch = input_surface.pitch;
@@ -745,5 +750,12 @@ namespace pydeepstream {
},
"data"_a,
pydsdoc::methodsDoc::get_segmentation_masks);
+
+ /* Start binding for /sources/includes/gst-nvevent.h */
+ m.def("gst_nvevent_new_stream_reset",
+ [](uint32_t source_id) {
+ return gst_nvevent_new_stream_reset(source_id);
+ },
+ pydsdoc::methodsDoc::gst_nvevent_new_stream_reset);
}
}
diff --git a/bindings/src/pyds.cpp b/bindings/src/pyds.cpp
index 5ecb8b4..db662c3 100644
--- a/bindings/src/pyds.cpp
+++ b/bindings/src/pyds.cpp
@@ -34,7 +34,7 @@
#include */
-#define PYDS_VERSION "1.1.2"
+#define PYDS_VERSION "1.1.3"
using namespace std;
namespace py = pybind11;
diff --git a/docs/PYTHON_API/Methods/methodsdoc.rst b/docs/PYTHON_API/Methods/methodsdoc.rst
index d3452bd..1c2cc02 100644
--- a/docs/PYTHON_API/Methods/methodsdoc.rst
+++ b/docs/PYTHON_API/Methods/methodsdoc.rst
@@ -1,3 +1,9 @@
+======================
+gst_nvevent_new_stream_reset
+======================
+
+.. autofunction:: pyds.gst_nvevent_new_stream_reset
+
======================
get_segmentation_masks
======================
diff --git a/tests/integration/README.md b/tests/integration/README.md
index 34d09ee..3147b6f 100644
--- a/tests/integration/README.md
+++ b/tests/integration/README.md
@@ -55,7 +55,7 @@ python3.8 -m venv env
### step3
```
. env/bin/activate
-pip install pyds-1.1.2-py3-none-*.whl
+pip install pyds-1.1.3-py3-none-*.whl
pip install pytest
cd ../../tests/integration
pytest test.py