Sample app nvdsanalytics, differentiate between objects out of ROI vs ROI filtering disabled condition

PC: RTX 2070 Super
Deepstream: 6.4
Driver Version: 535.154.05
Docker image: deepstream:6.4-gc-triton-devel

I am working on the sample app deepstream-nvdsanalytics-test in C++ for deepstream 6.4. I can compile and use the app correctly.

My use case is as below

  1. If roi filtering is enabled for the stream, I would like to process objects inside the ROI with function X.
  2. If roi filtering is disabled for the stream, I would like to process all objects with function X

However my issue is that, within this probe function, if an object does not contain any usermeta NVDS_USER_OBJ_META_NVDSANALYTICS, there is no way to know, if this is because the object is outside the ROI or if roi filtering is disabled for this stream.

Thus my question, is there any way to know if roi filtering is active or not per stream during probe.

    for (l_obj = frame_meta->obj_meta_list; l_obj != NULL; )
    {
      obj_meta = (NvDsObjectMeta *)(l_obj->data);
      NvDsMetaList *obj_next = l_obj->next;

        bool is_in_roi=false;
        for (NvDsMetaList *l_user_meta = obj_meta->obj_user_meta_list; l_user_meta != NULL; l_user_meta = l_user_meta->next) {
          NvDsUserMeta *user_meta = (NvDsUserMeta *) (l_user_meta->data);
          if(user_meta->base_meta.meta_type == NVDS_USER_OBJ_META_NVDSANALYTICS)
          {
              NvDsAnalyticsObjInfo * user_meta_data = (NvDsAnalyticsObjInfo *)user_meta->user_meta_data;
              if(user_meta_data->roiStatus.size()>0){
                is_in_roi = true;
              }
          }
        }
    if(is_in_roi){
  // Process objects with function X
    }
    l_obj = obj_next;
    }
[roi-filtering-stream-0]
enable=1
roi-RF=50;500;1870;500;1870;1030;50;1030
inverse-roi=0
class-id=-1

I am checking.

NVDSANALYTICS meta includes the analyses results, if there is no NVDSANALYTICS meta, we don’t know if ROI is enabled or the objects are outside of ROI.
nvdsanalytics plugin is opensource. you can modify the nvdsanalytics to customize. for example, you can add an user meta including is_in_roi after getting analyses in nvdsanalytics plugin code, then in probe function, retrieve this data from user meta. the code path is /opt/nvidia/deepstream/deepstream/sources/gst-plugins/gst-nvdsanalytics/.

There seems to be a work-around without modifying the plugin as well.
With the code below we use the flag is_nvds_analytics_enabled to check if the roi filter is enabled for this stream, thanks to the information inside frame meta.
Then use is_in_roi in combination with is_nvds_analytics_enabled as needed.

  for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
       l_frame = l_frame->next)
  {
    bool is_nvds_analytics_enabled = false;
    for (NvDsMetaList * l_user = frame_meta->frame_user_meta_list; l_user != NULL; l_user = l_user->next) {
      NvDsUserMeta *user_meta = (NvDsUserMeta *) l_user->data;
      if (user_meta->base_meta.meta_type != NVDS_USER_FRAME_META_NVDSANALYTICS)
          continue;

      NvDsAnalyticsFrameMeta *meta = (NvDsAnalyticsFrameMeta *) user_meta->user_meta_data;
      if (meta->objInROIcnt.size()>0)
        is_nvds_analytics_enabled = true;
    }
....
....

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.