WHCSRL 技术网

Deepstream 的Python Sample Apps

基础环境

我的是Deepstream5.1环境:安装Deepstream5.1
Ubuntu 18.04
DeepStream SDK 5.1 or later
Python 3.6
Gst Python v1.14.5

1.下载deepstream_python_apps

Clone 项目到DeepStream 5.1/sources下

cd /opt/nvidia/deepstream/deepstream-5.1/sources
sudo git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps
cd /opt/nvidia/deepstream/deepstream/lib
sudo python3 setup.py install
  • 1
  • 2
  • 3
  • 4

尝试能否直接运行Demo:

cd apps/deepstream-test1
python3 deepstream_test_1.py <input .h264 file>
  • 1
  • 2

若不能直接运行则进行以下编译

2.Deepstream python bindings

安装所需要的依赖和Gst-python

sudo 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
sudo apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
cd /opt/nvidia/deepstream/deepstream-5.1/sources/deepstream_python_apps/
  • 1
  • 2
  • 3

3.安装pybind11

安装python调用C++利器pybind11

git clone https://github.com/pybind/pybind11.git
sudo pip3 install pytest
cd pybind11/
mkdir build
cd build
cmake ..
cmake --build . --config Release --target check
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

4.Building the bindings

编译bindings

cd deepstream_python_apps/bindings
mkdir build
cd build
cmake ..
make
  • 1
  • 2
  • 3
  • 4
  • 5

也可以自定义编译参数:
自定义cmake参数
例如:

cd deepstream_python_apps/bindings
mkdir build
cd build
cmake ..  -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=6 -DPIP_PLATFORM=linux_x86_64 -DDS_PATH=/opt/nvidia/deepstream/deepstream-5.1/
make
  • 1
  • 2
  • 3
  • 4
  • 5

若出现找不到pybind11.h文件错误,则修改build同级目录下的CMakeLists.txt文件,导入正确的pybind11.h文件路径

sudo find / -name pybind11.h #查看pybind11.h路径
  • 1

5.Using the generated pip wheel and Run Demo

安装编译好的轮子包

sudo pip3 install ./pyds-1.1.0-py3-none*.whl
cd apps/deepstream-test1
python3 deepstream_test_1.py <input .h264 file>
  • 1
  • 2
  • 3

成功运行python文件

运行成功
下一步查看python文件源码,更改自己的Model…

respect

推荐阅读