Access Metadata of objects crossing lines in deepstream-nvdsanalytics-test

• Hardware Platform (Jetson / GPU) - Tesla T4/P4
• DeepStream Version - DS 5.1
• TensorRT Version - 7.2.1.6
• NVIDIA GPU Driver Version (valid for GPU only) - 460.91.03
• Cuda Version - 11.1
• Issue Type( questions, new requirements, bugs) - Access metadata of all objects crossing lines in nvdsanalytics
• 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) - I am using the sample application deepstream-nvdsanalytics-test

Command to run - ./deepstream-nvdsanalytics-test file:///home/ram/Videos/Loc1.mp4

• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

I am trying to running and extract the metadata of the detected objects by running the deepstream-nvdsanalytics-test. I am running the application to count the number of vehicles in lanes and classify them.

So far from my understanding there are following parameters for line crossing in the config_nvdsanalytics.txt

[line-crossing-stream-0]
enable=1
#Label;direction;lc
#Location1 Video lines
line-crossing-Entry=500;751;703;650;531;673;793;712
line-crossing-Exit=1150;672;1050;900;720;770;1150;800

And I have set the lines as in the image below and its detecting and counting the vehicles

Queries

  • How can i get the metadata of the objects that crossed the Exit and Entry lines separately?

  • How to get the label and id of the object that crossed a particular line i.e Entry or Exit?
    Eg:

VehicleID : 1
Lane : Entry

VehicleID: 2
Lane : Exit

  • How to add new entry and exit lines in the config?

  • Should i use both the entry and exit lines in the same lane for a stream ? Please correct me if I’m going wrong in any part.

Please check nvdsanalytics_src_pad_buffer_probe() in deepstream_nvdsanalytics_test.cpp
lcStatus in NvDsAnalyticsObjInfo can show the entry and exit status for each object

Label and id are in object meta. NVIDIA DeepStream SDK API Reference: _NvDsObjectMeta Struct Reference. Please also check nvdsanalytics_src_pad_buffer_probe() for reference.

It should be configured in nvdsanalytics config file.NvDsAnalyticsExt — DeepStream 6.0 Release documentation. There is a sample in /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-nvdsanalytics-test/config_nvdsanalytics.txt

No such limitation

@Fiona.Chen

I have noticed lcStatus in nvds_analytics_meta.h and I tried to print the value but I didn’t get the exact output for the linecrossing

Filename: nvds_analytics_meta.h

/**
 * Holds a set of nvdsanalytics object level metadata.
 */
typedef struct
{
/** Holds the array of ROI labels in which object is present */
  std::vector <std::string> roiStatus;
 /** Holds the array  of OverCrowding labels in which object is present  */
  std::vector <std::string> ocStatus;
 /** Holds the array of line crossing labels which object has crossed */
  std::vector <std::string> lcStatus;
 /** Holds the direction string for the tracked object */
  std::string dirStatus;
 /** Holds unique identifier for nvdsanalytics instance */
  guint unique_id;
} NvDsAnalyticsObjInfo;

I have printed only objectID and lcStatus after the object crosses the line, if this is correct im getting the wrong output

Filename: deepstream_nvdsanalytics_test.cpp

static GstPadProbeReturn
nvdsanalytics_src_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info,
    gpointer u_data)
{
    GstBuffer *buf = (GstBuffer *) info->data;
    guint num_rects = 0;
    NvDsObjectMeta *obj_meta = NULL;
    guint vehicle_count = 0;
    guint person_count = 0;
    NvDsMetaList * l_frame = NULL;
    NvDsMetaList * l_obj = NULL;

    NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buf);

    for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
      l_frame = l_frame->next) {
        NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
        std::stringstream out_string;
        vehicle_count = 0;
        num_rects = 0;
        person_count = 0;
        for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;
                l_obj = l_obj->next) {
            obj_meta = (NvDsObjectMeta *) (l_obj->data);
            if (obj_meta->class_id == PGIE_CLASS_ID_VEHICLE) {
                vehicle_count++;
                num_rects++;
            }
            if (obj_meta->class_id == PGIE_CLASS_ID_PERSON) {
                person_count++;
                num_rects++;
            }

            // Access attached user meta for each object
            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);
                int id = obj_meta->object_id;

               
                if(user_meta->base_meta.meta_type == NVDS_USER_OBJ_META_NVDSANALYTICS)
                {
                    NvDsAnalyticsObjInfo * user_meta_data = (NvDsAnalyticsObjInfo *)user_meta->user_meta_data;
                    
                    g_print("ID:%d\n",id);
                    g_print("LineCrossingStatus:%s\n", user_meta_data->lcStatus);

                    if (user_meta_data->dirStatus.length()){
                        g_print ("object %lu moving in %s\n", obj_meta->object_id, user_meta_data->dirStatus.c_str());
                    }
                }
            }
        }
    }
    return GST_PAD_PROBE_OK;
}

Output:

ID:9
[Invalid UTF-8] LineCrossingStatus:`\xa7

ID:4
[Invalid UTF-8] LineCrossingStatus:`\xa7

ID:25
[Invalid UTF-8] LineCrossingStatus:\x80\xb1

ID:35
[Invalid UTF-8] LineCrossingStatus:\xb0\xed

ID:22
[Invalid UTF-8] LineCrossingStatus:`\xa7

ID:31
LineCrossingStatus:)8

Can you please help me on this

Can anyone please help on this issue

@RajeshMuthuswamy lcStatus is a string vector. You can not print in this way.

@Fiona.Chen Ok will check on that

@Fiona.Chen

I managed to get the label info from lcStatus for each object using the below code.

  std::stringstream lane_string;

// Access attached user meta for each object
            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;

                    std::vector<std::string> lane(user_meta_data->lcStatus);
                    for(int i=0; i<lane.size();i++)
                    {
                      lane_string << lane[i];
                    }
                     g_print("LineLabel : %s \n",lane_string.str().c_str());

                    // Line Direction 
                    if (user_meta_data->dirStatus.length()){
                        g_print ("object %lu moving in %s\n", obj_meta->object_id, user_meta_data->dirStatus.c_str());
                    }
                }
            }

Thanks

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