Custom frame information to eventmsgmeta

1、how to add the custom frame information to NvDsFrameMeta?
2、how to use dsmeta_payload.cpp ?(That msg2pNewApi set True is not worked .NVDS_CUSTOM_MSG_BLOB)
3、NvDsEventMsgMeta is only used to add the information of object, not instead of the custom frame information?

Hi @18241266008

NvDsEventMsgMeta is a type of DeepStream user meta and there is a NvDsUserMetaList in the batch, frame and object levels of DeepStream metadata, so you can add message meta per-batch, per-frame, or per-object. We use it on the batch level adding a JSON as message meta:

void
add_meta_to_buffer (GstBuffer * buf, gchar * meta)
{
  NvDsBatchMeta *batch_meta;
  NvDsUserMeta *user_meta;
  batch_meta = gst_buffer_get_nvds_batch_meta (buf);
  user_meta = nvds_acquire_user_meta_from_pool (batch_meta);
  if (user_meta) {
    NvDsEventMsgMeta *msg_meta =
        (NvDsEventMsgMeta *) g_malloc0 (sizeof (NvDsEventMsgMeta));
    msg_meta->otherAttrs = meta;
    msg_meta->objectId = g_strdup ("custom");
    user_meta->user_meta_data = (void *) msg_meta;
    user_meta->base_meta.batch_meta = batch_meta;
    user_meta->base_meta.meta_type = NVDS_EVENT_MSG_META;
    user_meta->base_meta.copy_func = (NvDsMetaCopyFunc) custom_meta_copy_func;
    user_meta->base_meta.release_func =
        (NvDsMetaReleaseFunc) custom_meta_free_func;
    nvds_add_user_meta_to_batch (batch_meta, user_meta);
  }
}

To get the meta on the other element that uses it:

  NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buffer);
  if (NULL == batch_meta){
    g_print ("No DeepStream meta found\n");
    return;
  }
  NvDsUserMetaList *user_meta_list = batch_meta->batch_user_meta_list;
  while (user_meta_list != NULL) {
    NvDsUserMeta *user_meta = (NvDsUserMeta *) user_meta_list->data;
    if (user_meta->base_meta.meta_type == NVDS_EVENT_MSG_META) {
      NvDsEventMsgMeta *msg_meta =
          (NvDsEventMsgMeta *) user_meta->user_meta_data;
      if (g_strcmp0 (msg_meta->objectId, "custom") == 0) {
        g_print ("CustomMeta\n%s\n", msg_meta->otherAttrs);
      }
    }
    user_meta_list = user_meta_list->next;
  }

I hope this helps

1 Like

Thanks a lot.
How to get the custom frame information in generate_event_message_minimal function in eventmsg_payload.cpp , from NvDsEventMsgMeta \ events[0].metadata \ user_meta ?My NvDsEventMsgMeta achieved in bbox_generated_probe_after_analytics through create_pipeline

There is no update from you for a period, assuming this is not an issue anymore.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

sorry for the late reply, yes, you can add user information in user meta, please refer to sample deepstream-user-metadata-test, which saves user data in user meta.

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