Avoid tracking for specific class ID to re-infer the given class ROI for every frame

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) x86 RTX-3060
• DeepStream Version 6.1
• JetPack Version (valid for Jetson only) N/A
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only) 525.125.06
• Issue Type( questions, new requirements, bugs) questions
• 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)

I have a specific requirement to modify the existing deepstream-app in order to skip or avoid tracking for specific class ID, however as per some exiting threads or similar topic doesn’t seems to address my problem as pointed out in post #232376, in my case i want to skip tracking only for specif class_id and allow the rest of the detected class_id to go through the tracking element, so i don’t find any straight forward way to achieve this using main app config or something similar, hence i intercepted the tracking probe function and tried to nullify the object_id(tracking ID) and other relevant attributes assigned by the tracking element for the specific class ID as below,

static void write_kitti_track_output (AppCtx * appCtx, NvDsBatchMeta * batch_meta)
  for (NvDsMetaList * l_frame = batch_meta->frame_meta_list; l_frame != NULL;
      l_frame = l_frame->next) {
    NvDsFrameMeta *frame_meta = l_frame->data;
    guint stream_id = frame_meta->pad_index;

    for (NvDsMetaList * l_obj = frame_meta->obj_meta_list; l_obj != NULL;
        l_obj = l_obj->next) {
      NvDsObjectMeta *obj = (NvDsObjectMeta *) l_obj->data;
      if(obj->class_id == 9)
        obj->tracker_confidence = 0;
        obj->object_id = (void *)NULL;
        GstBuffer *buf = (GstBuffer *) obj;
        g_mutex_lock (&appCtx->app_lock);
        nvds_copy_gst_meta_to_frame_meta(buf, batch_meta, frame_meta);
        g_mutex_unlock (&appCtx->app_lock);

As per above code i tried to directly change the NvDsObjectMeta *obj with attributes obj->tracker_confidence and obj->object_id to null which should imply no tracking ID is associated for the given class ID and sgie will infer the ROI for given class ID for every frame. But nvds_copy_gst_meta_to_frame_meta function is giving segmentation fault while running the app.

So what could be the possible work around for this issue.
Thank you.

If your SGIE works in async mode, you just need set object_meta->object_id = UNTRACKED_OBJECT_ID. Why you need nvds_copy_gst_meta_to_frame_meta?

Thank You for the response,
I set the sgie to classifier-async-mode=1 for async classification mode, and as you pointed out i directly set the tracking attributes without nvds_copy_gst_meta_to_frame_meta function as below,

if(obj->class_id == 9)
        //NvDsObjectMeta *lobj;
        // obj->tracker_confidence = -1;
        obj->object_id = UNTRACKED_OBJECT_ID;
        // GstBuffer *buf = (GstBuffer *) obj;
        // g_mutex_lock (&appCtx->app_lock);
        // nvds_copy_gst_meta_to_frame_meta(buf, batch_meta, frame_meta);
        // g_mutex_unlock (&appCtx->app_lock);

After running this, the tracking ID doesn’t get’s displayed when the app is running, it means that the modified tracking attributes works correctly without nvds_copy_gst_meta_to_frame_meta function but the re-inferencing is still not happening which implies tracking is still working for given sgie , which is avoiding re-inferencing for sgie classifier.

There is one function should_infer_object () in gstnvinfer.cpp. Can you hack in this function for your feature instead of modify the object_id?

1605 /* Function to decide if object should be inferred on. */
1606 static inline gboolean
1607 should_infer_object (GstNvInfer * nvinfer, GstBuffer * inbuf,
1608 NvDsObjectMeta * obj_meta, gulong frame_num,
1609 GstNvInferObjectHistory * history)

1 Like

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