Display polygon on every frame using osd_sink_pad_buffer_probe

Please provide complete information as applicable to your setup.

**• Hardware Platform (Jetson / GPU)**Orin
• DeepStream Version7.1
**• JetPack Version (valid for Jetson only)**6.1
The following code displays only one line on the first image.
I have four sources in display screen like

tiled-display:
  enable: 1
  rows: 2
  columns: 2
  width: 1280
  height: 720
  gpu-id: 0
  #(0): nvbuf-mem-default - Default memory allocated, specific to particular platform
  #(1): nvbuf-mem-cuda-pinned - Allocate Pinned/Host cuda memory, applicable for Tesla
  #(2): nvbuf-mem-cuda-device - Allocate Device cuda memory, applicable for Tesla
  #(3): nvbuf-mem-cuda-unified - Allocate Unified cuda memory, applicable for Tesla
  #(4): nvbuf-mem-surface-array - Allocate Surface Array memory, applicable for Jetson
  nvbuf-memory-type: 0

But the polygon is displayed on the first image.
How can I make polygon is drawn on all images?

static GstPadProbeReturn
osd_sink_pad_buffer_probe(GstPad *pad, GstPadProbeInfo *info,
                          gpointer u_data)
{
  GstBuffer *buf = (GstBuffer *)info->data;
  guint num_rects = 0;
  NvDsObjectMeta *obj_meta = NULL;
  NvDsMetaList *l_frame = NULL;
  NvDsMetaList *l_obj = NULL;
  NvDsDisplayMeta *display_meta = NULL;
  gboolean is_first_object = TRUE;
  NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta(buf);

  for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
       l_frame = l_frame->next)
  {
    is_first_object = TRUE;
    NvDsFrameMeta *frame_meta = (NvDsFrameMeta *)(l_frame->data);    
    display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
    int p_cnt = 0;
    int start_x = 50;
    int start_y = 50;
    for(int p=0; p < 20; p++){
      NvOSD_LineParams *line_params = &display_meta->line_params[p];
      if(p == 0){
         line_params->x1 = start_x;
         line_params->y1 = start_y;
      }else{
         start_x+=10;
         start_y+=10;
         line_params->x1 = start_x;
         line_params->y1 = start_x;
      }
      line_params->x2 = start_x+10;
      line_params->y2 = start_y+10;
      line_params->line_width = 2;
      line_params->line_color.red = 0.0;
      line_params->line_color.green = 0.0;
      line_params->line_color.blue = 1.0;
      line_params->line_color.alpha = 1.0;
      p_cnt++;
    }
    display_meta->num_lines = p_cnt;
    nvds_add_display_meta_to_frame(frame_meta, display_meta);
    
  }
  frame_number++;
  return GST_PAD_PROBE_OK;
}

Could you attach your whole pipeline? And where did you add the probe function?

This is the whole code inside osd_sink_pad_buffer_probe
I am using deepstream-parallel-infer app. osd_sink_pad_buffer_probe is in the deepstream_parallel_infer_app.cpp

static GstPadProbeReturn
osd_sink_pad_buffer_probe(GstPad *pad, GstPadProbeInfo *info,
                          gpointer u_data)
{
  GstBuffer *buf = (GstBuffer *)info->data;
  guint num_rects = 0;
  NvDsObjectMeta *obj_meta = NULL;
  NvDsMetaList *l_frame = NULL;
  NvDsMetaList *l_obj = NULL;
  NvDsDisplayMeta *display_meta = NULL;
  gboolean is_first_object = TRUE;
  NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta(buf);

  for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
       l_frame = l_frame->next)
  {
    is_first_object = TRUE;
    NvDsFrameMeta *frame_meta = (NvDsFrameMeta *)(l_frame->data);    
    display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
    int p_cnt = 0;
    int start_x = 50;
    int start_y = 50;
    for(int p=0; p < 20; p++){
      NvOSD_LineParams *line_params = &display_meta->line_params[p];
      if(p == 0){
         line_params->x1 = start_x;
         line_params->y1 = start_y;
      }else{
         start_x+=10;
         start_y+=10;
         line_params->x1 = start_x;
         line_params->y1 = start_x;
      }
      line_params->x2 = start_x+10;
      line_params->y2 = start_y+10;
      line_params->line_width = 2;
      line_params->line_color.red = 0.0;
      line_params->line_color.green = 0.0;
      line_params->line_color.blue = 1.0;
      line_params->line_color.alpha = 1.0;
      p_cnt++;
    }
    display_meta->num_lines = p_cnt;
    nvds_add_display_meta_to_frame(frame_meta, display_meta);
    
  }
  frame_number++;
  return GST_PAD_PROBE_OK;
}

OK. You sould add the probe to the sink pad of the tiler plugin instead of the nvsdosd. Because after the tiler plugin, there’s only one video in the batch.

Thanks. Which cpp sample I should follow for attaching probe to tiler sink pad?

You can just modify the code below from nvdsosd plugin to tiler plugin.

gst_element_get_static_pad(<tiler_plugin>, "sink");

deepstream_parallel_infer_app.cpp

Thanks it works now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.