Drawing a rectangle/roi in Deepstream 4.0.1 using NvOSD_RectParams

I’ve been trying to draw a roi using deepstreams nvosd struct, so far I was able to achieve text display using nvosd structure. But I am unable to have the roi being displayed on screen.

display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
        txt_params  = display_meta->text_params;
        display_meta->num_labels = 1;
        rect_params = display_meta->rect_params;

        // if (txt_params->display_text)
        //   g_free (txt_params->display_text);
        txt_params->display_text = (char *) g_malloc0 (MAX_DISPLAY_LEN);

        rect_params->left = 100;
        rect_params->top = 300;
        rect_params->width = 500;
        rect_params->height = 500;
        rect_params->border_color.red = 1;
        rect_params->border_color.blue = 1;
        rect_params->border_color.green = 1;
        rect_params->border_color.alpha = 1;
        rect_params->has_bg_color = 1;
        rect_params->border_width = 5;
        rect_params->color_id = 1;
        rect_params->has_color_info = 1;


        update_fps(frame_meta->source_id);

        offset = snprintf(txt_params->display_text, MAX_DISPLAY_LEN, "Source: %d  FPS: %d",
                  frame_meta->source_id, fps[frame_meta->source_id].display_fps);
        offset = snprintf(txt_params->display_text + offset, MAX_DISPLAY_LEN, "People: %d  Faces: %d",
                  person_count, face_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 = (char *)"Serif";
        txt_params->font_params.font_size = 14;
        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;

        nvds_add_display_meta_to_frame(frame_meta, display_meta);

Hi,

Can you clarify the following -

  1. What platform are you using ?
  2. Can you specify the full pipeline you are running ? And where exactly you are updating the metadata ?

You can also have a look at the ds-example plugin which adds static bounding boxes to the metadata

Hello,

I’m also trying to figure out the same. I’ve followed the instructions here https://devtalk.nvidia.com/default/topic/1063752/deepstream-sdk/i-want-to-know-how-to-use-roi-top-offset-roi-bottom-offset/ to acquire display_meta and draw lines on OSD and put the code into deepstream_test1_app. My expectation was that a polygon is drawn on screen and detections will only happen if an object passes through the polygon. Unfortunately, nothing is being drawn and the app behaves exactly as before.

I’m on Jetson Nano btw, latest DeepStream release.

Any advice would be greatly appreciated.

Thanks,
Rob

Thread continued here - https://devtalk.nvidia.com/default/topic/1063752/deepstream-sdk/i-want-to-know-how-to-use-roi-top-offset-roi-bottom-offset/post/5391209/#5391209