Deepstream4.0在图像上overlay的方法

一、应用场景

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

二、运行环境

  1. jetson-nano板卡
  2. deepstream4.0
  3. 操作系统参考:
    《JETSON-Nano刷机运行deepstream4.0的demo》
    https://blog.csdn.net/shajiayu1/article/details/102669346

三、插件使用方法

  1. sudo apt-get install libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libopencv-dev
  2. cd gst-dsexample
  3. make
  4. sudo make install
  5. 步骤说明
    第一步是安装必要的软件
    编译后生成库文件,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文件的说明

  1. static GstFlowReturn
    gst_dsexample_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf)
    该函数实现大部分的功能。这个函数里面调用了下面的2、3、4三个函数。上游的元素把数据放到buffer里会调用该函数。
  2. 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可以操作的图像格式。还可以进行图像缩放。
  3. static void
    attach_metadata_full_frame (GstDsExample * dsexample, NvDsFrameMeta *frame_meta,
    gdouble scale_ratio, DsExampleOutput * output, guint batch_id)
    该函数是对整帧图像的处理。
  4. 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

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值