How to add arrow on screen?

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU): Jetson AGX Xavier
• DeepStream Version: 5.0
• JetPack Version (valid for Jetson only): 4.4
• TensorRT Version: 7.1.3
• Issue Type( questions, new requirements, bugs): question

I used the following code to add an arrow on to the screen but the arrow doesn’t appear. The start & end coordinates stay within the frame boundary of both the stream muxer and the inference model. I want to draw a horizontal line so the y-dim of start and end are equal, and x-start < x-end. The arrow width is 6px and in black colour. I want to ask why the arrow is not displayed on screen but the text does?

// muxer output width  640 
// muxer output height 360 
// model input width = 960
// model input height = 544

static GstPadProbeReturn
osd_sink_pad_buffer_probe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
{
  GstBuffer *buf = (GstBuffer *)info->data;
  guint num_rects = 0;
  NvDsFrameMeta *frame_meta = NULL;
  NvDsObjectMeta *obj_meta = NULL;
  NvDsDisplayMeta *display_meta = NULL;
  guint vehicle_count = 0;
  guint person_count = 0;
  NvDsMetaList *l_frame = NULL;
  NvDsMetaList *l_obj = NULL;
  
  // extracts the NvDsBatchMeta from the Gst Buffer
  NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta(buf);

  // process each NvDsFrameMeta in NvDsBatchMeta
  for (l_frame = batch_meta->frame_meta_list; l_frame != NULL; l_frame = l_frame->next)
  { 
    frame_meta = (NvDsFrameMeta *)(l_frame->data);
    int offset = 0;
    // process each NvDsObjectMeta in a NvDsFrameMeta
    for (l_obj = frame_meta->obj_meta_list; l_obj != NULL; l_obj = l_obj->next)
    {
      obj_meta = (NvDsObjectMeta *)(l_obj->data);
      
      if (obj_meta->class_id == PGIE_CLASS_ID_VEHICLE)
      {
        vehicle_count++;
        num_rects++;
      }
      if (obj_meta->class_id == PGIE_CLASS_ID_PERSON)
      {
        person_count++;
        num_rects++;
      }
    
      // add confidence with label to bbbox
      NvOSD_TextParams *text_params = &(obj_meta->text_params);
      snprintf(text_params->display_text, MAX_BBOX_LABEL_LEN, "%s @ %.2f", obj_meta->obj_label, obj_meta->confidence);
    }
    
    display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
    NvOSD_TextParams *txt_params = &display_meta->text_params[0];
    display_meta->num_labels = 1;
    txt_params->display_text = (char*) g_malloc0(MAX_DISPLAY_LEN);
    offset = snprintf(txt_params->display_text, MAX_DISPLAY_LEN, "Person = %d ", person_count);
    offset = snprintf(txt_params->display_text + offset, MAX_DISPLAY_LEN, "Vehicle = %d ", vehicle_count);

    /* Now set the offsets where the string should appear */
    txt_params->x_offset = 10;
    txt_params->y_offset = 12;

    /* Font , font-color and font-size */
    txt_params->font_params.font_name = "Courier";
    txt_params->font_params.font_size = 10;
    txt_params->font_params.font_color.red = 1.0;
    txt_params->font_params.font_color.green = 1.0;
    txt_params->font_params.font_color.blue = 1.0;
    txt_params->font_params.font_color.alpha = 1.0;

    /* Text background color */
    txt_params->set_bg_clr = 1;
    txt_params->text_bg_clr.red = 0.0;
    txt_params->text_bg_clr.green = 0.0;
    txt_params->text_bg_clr.blue = 0.0;
    txt_params->text_bg_clr.alpha = 1.0;

    // add horizontal line
    NvOSD_ArrowParams *arrow_params = &display_meta->arrow_params[0];
    display_meta->num_arrows = 1;
    arrow_params->x1 = 10; 
    arrow_params->x2 = 100;
    arrow_params->y1 = 150;
    arrow_params->y2 = 150;
    arrow_params->arrow_width = 6;
    arrow_params->arrow_head = BOTH_HEAD;
    arrow_params->arrow_color.red = 0.0;
    arrow_params->arrow_color.green = 0.0;
    arrow_params->arrow_color.blue = 0.0;
    arrow_params->arrow_color.alpha = 1.0;

    nvds_add_display_meta_to_frame(frame_meta, display_meta);
  }

  // g_print ("Frame Number = %d Number of objects = %d "
  //          "Vehicle Count = %d Person Count = %d\n",
  //          frame_number, num_rects, vehicle_count, person_count);
  frame_number++; 
  return GST_PAD_PROBE_OK;
}

arrow_head should be either START_HEAD or END_HEAD, BOTH_HEAD is not implemented yet.

Hey! Can anyone tell me how to do it in Python? I don’t know why, I am not able to set the arrow_head property. Should I set START_HEAD or END_HEAD as string?

Hi fixed-term.nuno.fernandes,

Please help to open a new topic for your issue. Thanks