I want to know how to use roi-top-offset, roi-bottom-offset

I want to know how to use roi-top-offset, roi-bottom-offset. There is no example anywhere.

roi-top-offset specifies that any detected object above the specified “y” coordinate will be rejected and won’t be part of metadata. Similarly, roi-bottom-offset specifies that any detected object below the specified “y” coordinate will be rejected and wont be part of metadata.
These values accept only “y” coordinates as argument. x coordinate is always assumed to be 0.

In case you want to specify the ROI in terms of polygon, you can do so by acquiring “dispay_meta” metadata and fill NvOSD_LineParams structure for each line that defines the ROI.

@srathi, could you provide a sample of having a polygon ROI as there seems to be multiple questions relating to this without a proper sample?

Below code demonstrates how to set ROI. You need to fill line parameters of all the lines defining polygon after acquiring display meta.

  NvOSD_LineParams *line_params  = &display_meta->line_params[0];
  line_params->x1 = 200;
  line_params->y1 = 200;
  line_params->x2 = 400;
  line_params->y2 = 400;
  line_params->line_width = 4;
  line_params->line_color.red = 1.0;
  line_params->line_color.green = 1.0;
  line_params->line_color.blue = 0.0;
  line_params->line_color.alpha = 0.7;
  display_meta->num_lines++;

  line_params  = &display_meta->line_params[1];
  line_params->x1 = 400;
  line_params->y1 = 400;
  line_params->x2 = 300;
  line_params->y2 = 650;
  line_params->line_width = 4;
  line_params->line_color.red = 1.0;
  line_params->line_color.green = 1.0;
  line_params->line_color.blue = 0.0;
  line_params->line_color.alpha = 0.7;
  display_meta->num_lines++;

  line_params  = &display_meta->line_params[2];
  line_params->x1 = 300;
  line_params->y1 = 650;
  line_params->x2 = 200;
  line_params->y2 = 650;
  line_params->line_width = 4;
  line_params->line_color.red = 1.0;
  line_params->line_color.green = 1.0;
  line_params->line_color.blue = 0.0;
  line_params->line_color.alpha = 0.7;
  display_meta->num_lines++;

  line_params  = &display_meta->line_params[3];
  line_params->x1 = 200;
  line_params->y1 = 650;
  line_params->x2 = 200;
  line_params->y2 = 200;
  line_params->line_width = 4;
  line_params->line_color.red = 1.0;
  line_params->line_color.green = 1.0;
  line_params->line_color.blue = 0.0;
  line_params->line_color.alpha = 0.7;
  display_meta->num_lines++;

Hi srathi,

thanks for sharing the above. Am I right in expecting objects to be recognised only within the defined region? Also, I was expecting the lines to show up on the video as it gets processed, but for some reason that’s not the case. Interestingly, when I run the app from a debugger (ddd), I can see the ROI lines in the defined positions, but objects still get recognised whether they’re within the ROI region or not.

Thanks,
Rob

Am I right in expecting objects to be recognized only within the defined region?

Sorry this feature is not supported at the moment and will be added in the future. However, nvinfer plugin sources are provided with the SDK so you can make the necessary changes straight away.

Polygon ROI inferencing is not supported and will be provided in a future release. But you can modify the nvinfer plugin to add ROI

Thanks guys, this actually helped me a lot and now I’ve got an understanding of what and where I need to modify to achieve my goal.

I’ll let you know about my progress and might share my solution in case anyone’s interested.

Thanks!

Hi srathi,

For some reason, the lines are drawn poorly: they flicker and look like dotted lines. I use python deepstream_test1 and test3.

Thanks,
Andrei

I have the same problem. Were you able to figure out a solution? I used deepstream-app and added lines in deepstream_app_main.c:overlay_graphics(). They are drawn but they flicker and have a dotted appearance.

I also see the same behaviour… Any who have solved this?

Hi Andrei, srathi and niels.kjaergaard.madsen,

Please open a new topic for your issue, be sure to test with DeepStream 5.0. Thanks