Problem with reading nvdsanalytics output via Kafka

Hi,
I am having difficulties with reading nvdsanalytics output via kafka. I generated a people counting app and I would like to send the “Entry” and “Exit” results to Kafka. I combined deepstream-test4 and deepstream-nvdsanalytics-test apps , and for modification I followed the instructions giving in the webinar “Create Intelligent Places Using NVIDIA Pre-trained vision Models and DeepStream SDK”.

Hardware Platform (Jetson / GPU): Jetson Nano
DeepStream Version: DP 5.0
JetPack Version (valid for Jetson only): 4.4

For this purpose, I created,

typedef struct{

guint32 lcc_cnt_exit;
guint32 lcc_cnt_entry;

} MyUserMeta;

Then, in nvdsanalytics_src_pad_buffer_probe function, I modified the code as below:

 MyUserMeta *user_data = (MyUserMeta *) g_malloc0(sizeof(MyUserMeta));

    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;

           user_data->lcc_cnt_entry = meta->objLCCumCnt["Entry"];
           user_data->lcc_cnt_exit = meta->objLCCumCnt["Exit"];

And, in generate_event_msg_meta function, I modified the code like this:

generate_event_msg_meta (gpointer data, gint class_id, NvDsObjectMeta * obj_params, MyUserMeta * obj_data)
{
NvDsEventMsgMeta *meta = (NvDsEventMsgMeta *) data;
meta->lccum_cnt_entry = obj_data->lcc_cnt_entry;
meta->lccum_cnt_exit = obj_data->lcc_cnt_exit ; 

Also I added these lines to nvdsmeta_schema:

typedef struct NvDsEventMsgMeta {
guint lccum_cnt_entry;
guint lccum_cnt_exit;
}

I modified nvmsgconv.cpp:

struct NvDsAnalyticsObject {
  string id;
  string desc;
  string source;
  string version;
  guint occupancy;
  guint lccum_cnt_entry;
  guint lccum_cnt_exit;
  
};

generate_analytics_module_object(){
json_object_set_double_member (analyticsObj, "Entry", meta->lccum_cnt_entry);
json_object_set_double_member (analyticsObj, "Exit", meta->lccum_cnt_exit);
}

I modified the Makefile and successfully built it.

So I am expecting to see “Entry” and “Exit” parts in the analyticsModule when I read the topic via Kafka. However, I didn’t manage. Do you have any idea to solve this?

Thank you.

Also I noticed that when I modified libs/nvmsgconv/nvmsgconv.cpp, nothing changes in the message keys.

“analyticsModule” :{
“id”: “string”,
“description”: “Vehicle Detection …”
“confidence”:97.79
“source”: “OpenALR”
}

For example, when I changed the line in nvmsgconv.cpp

json_object_set_string_member (analyticsObj, "objectid", dsObj->id.c_str());

instead of,

json_object_set_string_member (analyticsObj, "id", dsObj->id.c_str());

I still see the same analyticsModule with the key “id”.

Hello,

Probably haven’t updated the libnvds_msgconv.so?
Compile and install the nvmsgconv plugin at /opt/nvidia/deepstream/deepstream-5.0/sources/libs/nvmsgconv and then copy the libnvds_msgconv.so to /opt/nvidia/deepstream/deepstream-5.0/lib

Thank you for your reply. Actually I compiled it, there shouldn’t be a problem with that.

Did you update .so file at /opt/nvidia/deepstream/deepstream-5.0/lib? or updating the path in application makefile?

I defined this path for msgp-lib:

#define MSG2P_LIB "/opt/nvidia/deepstream/deepstream-5.0/sources/libs/nvmsgconv/libnvds_msgconv.so"

And I configured msgconv element with this.

g_object_set (G_OBJECT(msgconv), "msg2p-lib", MSG2P_LIB, NULL);

When I set payload-type NVDS_PAYLOAD_CUSTOM and modify the related part as below:

NvDsEventMsgMeta *meta = events[i].metadata;
    ss <<  meta->trackingId << "| " << meta->bbox.left << "| " <<  meta->bbox.top
        << "|"  << meta->bbox.left + meta->bbox.width << "|" <<  meta->bbox.top + meta->bbox.height
        << "| "  << meta->lccum_cnt_entry << "| " << meta->lccum_cnt_exit << "|" 
        << "| " << object_enum_to_str (meta->objType, meta->objectId);

I could see the entry and exit output.

However, when the payload-type has been set as NVDS_PAYLOAD_DEEPSTREAM and when I modified the generate_analytics_module as below:

generate_analytics_module_object(){
json_object_set_double_member (analyticsObj, "Entry", meta->lccum_cnt_entry);
json_object_set_double_member (analyticsObj, "Exit", meta->lccum_cnt_exit);
}

I cannot see exit and entry outputs.

Can confirm I get the same. If I use NVDS_PAYLOAD_DEEPSTREAM the entry and exit counts remain 0. If I change to minimal and add the above it sends the entry and exit count

Hi,
Have you resolve this problem, please
I have the same problem , exit and entry send me 0, and when i modify msgconv,no changes
Thanks

Hi, I still didn’t solve when I used NVDS_PAYLOAD_DEEPSTREAM as payload-type.
However, as I explained above I used NVDS_PAYLOAD_CUSTOM, and in nvmsgconv.cpp I modified the related part as below:

NvDsEventMsgMeta *meta = events[i].metadata;
    ss <<  meta->trackingId << "| " << meta->bbox.left << "| " <<  meta->bbox.top
        << "|"  << meta->bbox.left + meta->bbox.width << "|" <<  meta->bbox.top + meta->bbox.height
        << "| "  << meta->lccum_cnt_entry << "| " << meta->lccum_cnt_exit << "|" 
        << "| " << object_enum_to_str (meta->objType, meta->objectId);

I managed to obtain entry and exit counts in this way.

2 Likes

Thank you

Hi,

We now have a public Github repo for the analytics application. Please check this out https://github.com/NVIDIA-AI-IOT/deepstream-occupancy-analytics.

2 Likes