deepstream4.0在图像上叠加line或者label

Ann ·
更新时间:2024-09-20
· 964 次阅读

deepstream4.0在图像上叠加line或者label一、应用场景二、运行环境三、插件使用方法四、程序解读在dsexample_lib.c文件中gstdsexample.cpp文件的说明 一、应用场景

deepstream4.0可以完成摄像头数据的解码、模型的加速推理。有种应用场景是对推理后的图像增加line,矩形框或者label等。这就用到了deepstream的插件功能。插件的位置deepstream_sdk_v4.0.1_jetson\sources\gst-plugins\gst-dsexample。该功能可以在模型的推理后自己进行一些图像的处理。

二、运行环境 jetson-nano板卡 deepstream4.0 操作系统参考:
《JETSON-Nano刷机运行deepstream4.0的demo》
https://blog.csdn.net/shajiayu1/article/details/102669346 三、插件使用方法 sudo apt-get install libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libopencv-dev cd gst-dsexample make sudo make install 步骤说明
第一步是安装必要的软件
编译后生成库文件,sudo make install 是把库文件拷贝到相应的目录。
如果想调用插件需要把下面的拷贝到deepstream的配置文件里。
[ds-example]
enable=1
processing-width=640
processing-height=480
full-frame=0
unique-id=15
gpu-id=0
上面参数根据需要修改。
如果是拷贝到了deepstream-app的某个配置文件里。在执行deepstream-app的时候会调用插件的功能。
比如nano的板卡可以拷贝到
source8_1080p_dec_infer-resnet_tracker_tiled_display_fp16_nano.txt
该配置文件是deepstream4.0的配置文件,实现了16位精度的推理,同时对8路1080p的摄像头解码目标检测和跟踪。 四、程序解读

程序包含2个.C文件
gstdsexample.cpp和dsexample_lib.c

在dsexample_lib.c文件中

DsExampleOutput * DsExampleProcess (DsExampleCtx * ctx, unsigned char *data)
重点函数。实现了加标签的功能。该函数返回out把信息传递给gstdsexample.cpp

gstdsexample.cpp文件的说明 static GstFlowReturn
gst_dsexample_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf)
该函数实现大部分的功能。这个函数里面调用了下面的2、3、4三个函数。上游的元素把数据放到buffer里会调用该函数。 static GstFlowReturn
get_converted_mat (GstDsExample * dsexample, NvBufSurface *input_buf, gint idx,
NvOSD_RectParams * crop_rect_params, gdouble & ratio, gint input_width,
gint input_height)
该函数可以对图像格式进行处理,处理成opencv可以操作的图像格式。还可以进行图像缩放。 static void
attach_metadata_full_frame (GstDsExample * dsexample, NvDsFrameMeta *frame_meta,
gdouble scale_ratio, DsExampleOutput * output, guint batch_id)
该函数是对整帧图像的处理。 static void
attach_metadata_object (GstDsExample * dsexample, NvDsObjectMeta * obj_meta,
DsExampleOutput * output)
该函数是对整帧图像中每个目标的处理,比如给每个目标加标签。

参考文献:
[1]: https://docs.nvidia.com/metropolis/deepstream/dev-guide/index.html
[2]: https://docs.nvidia.com/metropolis/deepstream/dev-guide/index.html#page/DeepStream%2520Development%2520Guide%2Fdeepstream_custom_plugin.html%23wwpID0E0TB0HA
[3]: https://developer.nvidia.com/deepstream-sdk


作者:玩转deeplearning



line label

需要 登录 后方可回复, 如果你还没有账号请 注册新账号
相关文章