Plot rectangle on image

I am using deepstream-app with 4 streams of video.
I like to plot rectangles to highlight a few region of interests on images from 4 video streams.
How can I plot? Any sample for that?

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
Xavier
• DeepStream Version
5.1
• JetPack Version (valid for Jetson only)

R32 (release), REVISION: 4.3, GCID: 21589087, BOARD: t186ref, EABI: aarch64, DATE: Fri Jun 26 04:34:27 UTC 2020

• TensorRT Version
latest
• NVIDIA GPU Driver Version (valid for GPU only)
10.2
• Issue Type( questions, new requirements, bugs)
to plot rectangles to highlight a few region of interests on images
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)
to plot rectangles to highlight a few region of interests on images

Plot using gstdsexample is working for me.
Added gsddsexample to deepstream-app in config file and I can plot on cvmat inside the file.

I think you can just add the rectangle params and osd will do the draw work, refer NvOsd module API — Deepstream Deepstream Version: 5.1 documentation

That is good idea. How can I add rect_params to nvdsosd?

In the following code,

if (batch_meta)
    full_obj_meta_list = batch_meta->obj_meta_pool->full_list;
  NvDsObjectMeta *object_meta = NULL;

  for (l = full_obj_meta_list; l != NULL; l = l->next) {
    object_meta = (NvDsObjectMeta *) (l->data);
    if (nvdsosd->draw_bbox) {
      nvdsosd->rect_params[rect_cnt] = object_meta->rect_params;
#ifdef PLATFORM_TEGRA
      /* In case of hardware blending, values set in hw-blend-color-attr
         should be considered as rect bg color values*/
      if (nvdsosd->nvdsosd_mode == MODE_HW && nvdsosd->hw_blend) {
        for (idx = 0; idx < nvdsosd->num_class_entries; idx++) {
          if (nvdsosd->color_info[idx].id == object_meta->class_id) {
            nvdsosd->rect_params[rect_cnt].color_id = idx;
            nvdsosd->rect_params[rect_cnt].has_bg_color = TRUE;
            nvdsosd->rect_params[rect_cnt].bg_color.red =
              nvdsosd->color_info[idx].color.red;
            nvdsosd->rect_params[rect_cnt].bg_color.blue =
              nvdsosd->color_info[idx].color.blue;
            nvdsosd->rect_params[rect_cnt].bg_color.green =
              nvdsosd->color_info[idx].color.green;
            nvdsosd->rect_params[rect_cnt].bg_color.alpha =
              nvdsosd->color_info[idx].color.alpha;
            break;
          }
        }
      }
#endif
      rect_cnt++;
    }

full_obj_meta_list is taken from batch_meta.
full_obj_meta_list has object_meta = (NvDsObjectMeta *) (l->data);
object_meta has rect_params
nvdsosd->rect_params[rect_cnt] = object_meta->rect_params;

How can I add custom rectangle parameters to object_meta so that nvosd can plot?
Actually I need to draw mask. How to add to nvdsosd->mask_params?

Hi I am going to add mask params and according to _NvOSD_MaskParams Struct Reference.

float * data inside Struct represents the whole mask area in image or just contour of mask?

_NvOSD_MaskParams a;
object_meta->mask_params.push_back(a);

If push back custom maskparam to object_meta->mask_params, NvOSD can plot mask on image, right?