deepstream-python安装

安装deepstream-docker

在这边文章中deepstream-docker详细介绍了如何在Ubuntu下安装deepstream-docker,安装完成之后,为了快速入门deepstream,我们可以安装deepstream-python库,通过阅读相应的例子来快速搭建一个应用。

安装deepstream-python

在安装完成deepstream-docker之后,新建容器,在容器内部可以通过如下步骤进行deepstream-python的安装,过程如下:

查看deepstream的版本

deepstream-app -v

需要基于C++的deepstream版本安装对应python版本库,基本上在deepstream-python的readme都能看到如下的版本要求。deepstream-python安装_第1张图片

安装依赖库

在编译安装deepstream-python库之前,需要运行如下命令,安装相应的依赖库,以便后续编译正确运行。

apt-get update 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

下载项目

通常情况下,大家都习惯将deepstream-python的源码下载到如下路径进行安装。

cd /opt/nvidia/deepstream/deepstream/sources 

通过如下命令,可以下载deepstream-python对应的源文件。

export GIT_SSL_NO_VERIFY=true
git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps.git 

cd deepstream_python_apps # git submodule update --init

编译gst-python

由于网络问题通常情况下,3rdparty文件夹下依赖的第三方库无法clone下来,因此需要我们单独进行下载,并checkout到指定的版本下,然后进行编译安装。

cd deepstream_python_apps/3rdparty 
rm-rf *
git clone https://gitee.com/qst1998/gst-python.git 
cd gst-python 
git checkout 1a8f48a
 # 编译
 ./autogen.sh 
 make 
 make install

编译pybind11

如下图所示,deepstream通过pybind11提供python接口,因此,我们首先需要编译安装pybind11。
deepstream-python安装_第2张图片
安装pybind11的过程如下,同样在3rdparty文件夹下,先下载pybind11源码然后进行编译安装。

git clone https://gitee.com/qst1998/pybind11.git
cd ../pybind11

git checkout 3b1dbeb
 #编译 
 python3 setup.py install

编译python-binding

之后就是deepstream-python对应的bindings安装过程,编译时需要指定python的版本。

cd /opt/nvidia/deepstream/deepstream-6.1/sources/deepstream_python_apps/bindings 
mkdir build 
cd build 
cmake .. -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=8 
make -j

安装pyds

最后就是安装生成的pip whl轮子文件。

pip3 install pyds-1.1.4-py3-none-linux_x86_64.whl

测试

经过上述过程就完成deepstream-python库的安装,通过如下命令就能简单测试库是否正确安装

cd /opt/nvidia/deepstream/deepstream-6.1/sources/deepstream_python_apps/apps/deepstream-test1
python3 deepstream_test_1.py /opt/nvidia/deepstream/deepstream-6.1/samples/streams/sample_720p.h264

丰富的例子

deepstream-python项目中提供丰富的应用例子,大家可以根据自己的需求找到对应的app,然后修改app内容完成自己的功能
deepstream-python安装_第3张图片

总结

在本文中,进一步介绍了如何在deepstream-docker环境下安装deepstream-python库,方便大家快速入门deepstream。

你可能感兴趣的:(#,deepstream,python,deepstream)