DeepStream
Installation
CUDA and cuDNN
It is better to install cuda and cudnn using debian files as it helps in installation of dependencies.
Gstreamer
sudo apt install libssl1.0.0 libgstreamer1.0–0 gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav libgstrtspserver-1.0–0 libjansson4 ubuntu-restricted-extras libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
Dlib with CUDA support
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libx11-dev libatlas-base-dev
sudo apt-get install libpng-dev
sudo apt-get install libgtk-3-dev libboost-python-dev
GCC v6
sudo apt-get update &&
sudo apt-get install build-essential software-properties-common -y &&
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y &&
sudo apt-get update &&
sudo apt-get install gcc-6 g++-6 -y &&
sudo update-alternatives — install /usr/bin/gcc gcc /usr/bin/gcc-6 60 — slave /usr/bin/g++ g++ /usr/bin/g++-6 &&
gcc -v
wget http://dlib.net/files/dlib-19.17.tar.bz2
tar xvf dlib-19.17.tar.bz2
cd dlib-19.17/
mkdir build
cd build
cmake ..
cmake — build . — config Release
sudo make install
sudo ldconfig
cd ..
pkg-config — libs — cflags dlib-1
OPenCV with Gstreamer, CUDA and CudNN
Use the following command for cmake
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$(python3 -c “import sys; print(sys.prefix)”) -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_ENABLE_NONFREE=ON -D WITH_CUDA=ON -D WITH_CUDNN=ON -D OPENCV_DNN_CUDA=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D CUDA_ARCH_BIN=7.0 -D WITH_CUBLAS=1 -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules -D HAVE_opencv_python3=ON -D PYTHON_EXECUTABLE=$(which python3) -D BUILD_EXAMPLES=ON -D WITH_GSTREAMER=ON -DBUILD_LIBPROTOBUF_FROM_SOURCES=ON ..
make and make install are required to install the package
To find the prefix path, use: python3 -c “import sys; print(sys.prefix)” To find the install path: see install path in the output of cmake
To link the library: ls -l /usr/lib/python3.6/dist-packages/cv2/python-3.6
TensorRT 7.0
Download TensorRT 7.0 from the NVIDIA Developer Center: https://developer.nvidia.com/nvidia-tensorrt-download TensorRT 7.0.0.11 for Ubuntu 1804 and CUDA 10.2 DEB local repo packages
sudo apt-key add /var/nv-tensorrt-repo-cuda10.2-trt7.0.0.11-ga-20191216/7fa2af80.pub
sudo dpkg -i ./nv-tensorrt-repo-ubuntu1804-cuda10.2-trt7.0.0.11-ga-20191216_1–1_amd64.deb
sudo apt-get update
sudo apt-get install uff-converter-tf
sudo apt-get install build-essential dkms
sudo apt-get install freeglut3 freeglut3-dev libxi-dev libxmu-dev
sudo apt-get install tensorrt
git clone https://github.com/edenhill/librdkafka.git
cd librdkafka
git reset — hard 7101c2310341ab3f4675fc565f64f0967e135a6a
./configure
make
sudo make install
sudo mkdir -p /opt/nvidia/deepstream/deepstream-5.0/lib
sudo cp /usr/local/lib/librdkafka* /opt/nvidia/deepstream/deepstream-5.0/lib
DeepStream
Download the DeepStream 5.0 dGPU Debian package deepstream-5.0_5.0.1–1_amd64.deb : https://developer.nvidia.com/assets/Deepstream/5.0/ga/secure/deepstream_sdk
sudo apt-get install ./deepstream-5.0_5.0.1–1_amd64.deb
Python Bindings
sudo apt-get install python-gi-dev
export GST_LIBS=”-lgstreamer-1.0 -lgobject-2.0 -lglib-2.0"
export GST_CFLAGS=”-pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include”
git clone https://github.com/GStreamer/gst-python.git
cd gst-python
git checkout 1a8f48a
./autogen.sh PYTHON=python3
./configure PYTHON=python3
make
sudo make install
Running Sample Applications
Clone the deepstream_python_apps repo under <DeepStream 5.0 ROOT>/sources:
git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps
This will create the following directory:
<DeepStream 5.0 ROOT>/sources/deepstream_python_apps The Python apps are under the apps directory. Go into each app directory and follow instructions in the README.
Python apps: https://github.com/NVIDIA-AI-IOT/deepstream_python_apps
cd /opt/nvidia/deepstream/deepstream/lib
python3 setup.py install
sudo apt install python3-gi python3-dev python3-gst-1.0 -y
sudo apt install libgstrtspserver-1.0–0 gstreamer1.0-rtsp
sudo apt install libgirepository1.0-dev
sudo apt install gobject-introspection gir1.2-gst-rtsp-server-1.0
To run deepstream on live cameras, go to /opt/nvidia/deepstream/deepstream-5.0/sources/deepstream_python_apps/apps/deepstream-imagedata-multistream/
sudo python3 deepstream_imagedata-multistream.py camera-ip
Disable display of deepstream
#sink = Gst.ElementFactory.make(“nveglglessink”, “nvvideo-renderer”)
sink = Gst.ElementFactory.make("filesink", "filesink")if not sink: sys.stderr.write(" Unable to create filesink \n")
sink.set_property("location", "./out1.mp4")sink.set_property("sync", 1)sink.set_property("async", 0)
#if not sink:
#sys.stderr.write(" Unable to create egl sink \n")
Bounding boxes are only created for objects having confidence greater than the threshold
If any camera is not working using deepstream then following error will occur:
Error: gst-resource-error-quark: Could not open resource for reading and writing. (7): gstrtspsrc.c(7469): gst_rtspsrc_retrieve_sdp (): /GstPipeline:pipeline0/GstBin:source-bin-02/GstURIDecodeBin:uri-decode-bin/GstRTSPSrc:source: Failed to connect. (Generic error)