Prininting custom labels on Deepstream Frame

Hello, I’m using Deepstream sdk on Jeston xavier in order to run yolo with realtime performance.
I managed to extract the detection bounding boxes from the pipeline. But Now I need to print custom labels,circles ,etc… on the Deepstream image frame.
Is this is possible ?
How can I implement this behavior ?

• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)

Hi
You can add customized lables here, also circles,
sources/gst-plugins/gst-nvinfer/gstnvinfer_meta_utils.cpp::attach_metadata_detector
circle struct:
sources/includes/nvll_osd_struct.h::_NvOSD_CircleParams
and you need deepstream version 5.0 for circle

Hello @amycao
First of all thank you for your fast response, But I need more explanation in details please on How to attach any shape to my frame at specific locations.
For example I need to attach a shape(circle , dot , rectangle , …) at the center of the detected objects.
or this shape may be attached at any location in the image frame (u,v) according to some previous calculations.

May you provide me with the answer urgently Please?
Thanks in advance

Let’s take rectangle as example, it will draw rectangle from coordinates of left top corner downwards of width and height of object.

NvOSD_RectParams & rect_params = obj_meta->rect_params;

/* Assign bounding box coordinates. */
rect_params.left = obj.left;
rect_params.top = obj.top;
rect_params.width = obj.width;
rect_params.height = obj.height;

then customize accordingly.

Yes I follow up with this example, But what I need to do is to add extra rectangular in addition to the bounding box.
I need to plot the bounding box of the object and another box in the center of the object

You need to add another NvOSD_RectParams and change the coordinates of left corner of the rectangle you added and also width and height accordingly.

would it be something like this !

NvOSD_RectParams & rect_params = obj_meta->rect_params;
NvOSD_RectParams & my_rect_params = obj_meta->rect_params;

/* Assign bounding box coordinates. */
rect_params.left = obj.left;
rect_params.top = obj.top;
rect_params.width = obj.width;
rect_params.height = obj.height;

my_rect_params.left = left;
my_rect_params.top = top;
my_rect_params.width = width;
my_rect_params.height = height;

Hello @amycao,
When I tried the above code, it overwrote my custom box on all detected bounding boxes,
and when I tried to add

NvOSD_RectParams  my_rect_params; 

to NvDsObjectMeta in nvdsmeta.h
and trying to access this element of the structure by the following code:

NvOSD_RectParams & rect_params = obj_meta->rect_params;
NvOSD_RectParams & by_rect_params = obj_meta->my_rect_params;

/* Assign bounding box coordinates. */
rect_params.left = obj.left;
rect_params.top = obj.top;
rect_params.width = obj.width;
rect_params.height = obj.height;

by_rect_params.left = left;
by_rect_params.top = top;
by_rect_params.width = width;
by_rect_params.height = height;

It caused segmentation fault.
Could you help please ?

Hi
Here is one workable example, you may need to change the coordinates, width and height.
add under nvds_add_obj_meta_to_frame (frame_meta, obj_meta, parent_obj_meta);
build the plugin, and remember copy to /opt/nvidia/deepstream/deepstream-4.0/lib/gst-plugins/
and backup your original one.

display_meta = nvds_acquire_display_meta_from_pool (batch_meta);
NvOSD_RectParams *arect_params = display_meta->rect_params;
for ( int j=0; j < 1; j++ )
{
    arect_params[j].left = obj.left + 20;
    arect_params[j].top = obj.top + 20;
    arect_params[j].width = obj.width / 2;
    arect_params[j].height = obj.height / 2;
    arect_params[j].border_width = 2;
    arect_params[j].border_color = (NvOSD_ColorParams){0.0, 1.0, 0.0, 1.0};
    display_meta->num_rects ++;
}
 nvds_add_display_meta_to_frame (frame_meta, display_meta);

Hello amycao,
Thanks a lot for helping me. I can now print custom rects at specific position on the display.
But there is one more problem.
If I increase the number of rects over than 15 rects, it causes segmentation fault.
Do you know the solution for this fault?
Thanks in advance

You can draw maximum up to 16 elements like rectangle or line for 1 “display_meta”, If you wants to draw more than 16, needs to acquire additional “display_meta” and add remainings to it.

Thank you very much @amycao for your help