How to generate metadata on an object-by-object basis in deepstream-test5 app

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
3080ti
• DeepStream Version
6.1 triton

In the existing metadata format, object data is created per frame.
ex)
image

However, I want it to be created per object, not per frame.
I want to create only one object metadata at a time

so I try to modify source\libs\nvmsgconv\deepstream_schema\eventmsg_payload.cpp

But I don’t know how to fix it, so I’m asking like this

  1. every frame may have many objects, what do you mean about “every frame will have one or more than one object,”?
  2. eventmsg_payload.cpp is opensource, you can add logs to debug.

You can use nlohmann json inside a probe after you finish your analytics to put the object in the JSON format you want and send the meta-data object by object (after formatting it with nlohmann json) with librdkafka to the connection string and the topic you want.

I called the “generate_event_message” function as many times as the number of objects using the for statement in the “nvds_msg2p_generate” function.

so, I confirmed that the json string created in object units was stored in the “message” variable in “nvds_msg2p_generate” function

However, the metadata is saved in the variable, but when I checked the data transmitted from MongoDB, only one object data was saved for each frame.
I think the payload size is set to 1 so only one data is sent per frame. What should I do to solve this?

This is the code and output

NvDsPayload*
nvds_msg2p_generate (NvDsMsg2pCtx *ctx, NvDsEvent *events, guint size)
{
  gchar *message = NULL;
  gint len = 0;
  NvDsPayload *payload = (NvDsPayload *) g_malloc0 (sizeof (NvDsPayload));

  for(int i=0; i<size; i++)
  {
    NvDsEventMsgMeta *meta=events[i].metadata;
    if (ctx->payloadType == NVDS_PAYLOAD_DEEPSTREAM) {
      message = generate_event_message (ctx->privData, meta,size); //남겨둬
      if (message) {
        len = strlen (message);
        // Remove '\0' character at the end of string and just copy the content.
        payload->payload = g_memdup (message, len);
        payload->payloadSize = len;
        g_free (message);
      }
    } else if (ctx->payloadType == NVDS_PAYLOAD_DEEPSTREAM_MINIMAL) {
        NvDsEventMsgMeta *meta=events[i].metadata;
        message = generate_event_message_minimal (ctx->privData, meta, size);
        printf("%s\n", message);
 oid : 9
@ generate_schema_message: frameId=3
obj_tracking_id : 9
{
  "version" : "Nov 21 2022 06:03:10",
  "timestamp" : 20221121060326389,
  "id" : 3,
  "sensorId" : 0,
  "object" : {
    "id" : 9,
    "type" : "person",
    "bbox" : [
      296,
      441,
      183,
      425
    ],
    "attributes" : {
      "person" : 0.92797297239303589,
      "age" : 0.0,
      "gender" : 0.0,
      "backpack" : 0.0,
      "hat" : 0.0,
      "mask" : 0.0,
      "sunglass" : 0.0,
      "knife" : 0.0
    },
    "event" : {
      "id" : "abf50386-64bb-4e08-9cd1-20c85fd676e7",
      "type" : "custom(257)"
    }
  }
}
len : 545
p_len : 545
 oid : 8
@ generate_schema_message: frameId=3
obj_tracking_id : 8
{
  "version" : "Nov 21 2022 06:03:10",
  "timestamp" : 20221121060326389,
  "id" : 3,
  "sensorId" : 0,
  "object" : {
    "id" : 8,
    "type" : "person",
    "bbox" : [
      0,
      385,
      201,
      628
    ],
    "attributes" : {
      "person" : 0.92182183265686035,
      "age" : 0.0,
      "gender" : 0.0,
      "backpack" : 0.0,
      "hat" : 0.0,
      "mask" : 0.0,
      "sunglass" : 0.0,
      "knife" : 0.0
    },
    "event" : {
      "id" : "43e26e66-ee3a-429c-9d77-c25f855f7e7f",
      "type" : "custom(257)"
    }
  }
}
len : 543
p_len : 543
 oid : 7
@ generate_schema_message: frameId=3
obj_tracking_id : 7
{
  "version" : "Nov 21 2022 06:03:10",
  "timestamp" : 20221121060326389,
  "id" : 3,
  "sensorId" : 0,
  "object" : {
    "id" : 7,
    "type" : "person",
    "bbox" : [
      109,
      465,
      99,
      309
    ],
    "attributes" : {
      "person" : 0.72545462846755981,
      "age" : 0.0,
      "gender" : 0.0,
      "backpack" : 0.0,
      "hat" : 0.0,
      "mask" : 0.0,
      "sunglass" : 0.0,
      "knife" : 0.0
    },
    "event" : {
      "id" : "278e2e47-94e5-4c54-a0a7-693f9db714ad",
      "type" : "custom(257)"
    }
  }
}
len : 544
p_len : 544
 oid : 6
@ generate_schema_message: frameId=3
obj_tracking_id : 6
{
  "version" : "Nov 21 2022 06:03:10",
  "timestamp" : 20221121060326389,
  "id" : 3,
  "sensorId" : 0,
  "object" : {
    "id" : 6,
    "type" : "person",
    "bbox" : [
      430,
      478,
      32,
      63
    ],
    "attributes" : {
      "person" : 0.44704768061637878,
      "age" : 0.0,
      "gender" : 0.0,
      "backpack" : 0.0,
      "hat" : 0.0,
      "mask" : 0.0,
      "sunglass" : 0.0,
      "knife" : 0.0
    },
    "event" : {
      "id" : "bc89ea17-4a0c-4f90-891a-d863e5495b7a",
      "type" : "custom(257)"
    }
  }
}
len : 543
p_len : 543
 oid : 5
@ generate_schema_message: frameId=3
obj_tracking_id : 5
{
  "version" : "Nov 21 2022 06:03:10",
  "timestamp" : 20221121060326389,
  "id" : 3,
  "sensorId" : 0,
  "object" : {
    "id" : 5,
    "type" : "person",
    "bbox" : [
      440,
      477,
      41,
      73
    ],
    "attributes" : {
      "person" : 0.27274742722511292,
      "age" : 0.0,
      "gender" : 0.0,
      "backpack" : 0.0,
      "hat" : 0.0,
      "mask" : 0.0,
      "sunglass" : 0.0,
      "knife" : 0.0
    },
    "event" : {
      "id" : "a632fd17-e167-4125-adc6-9f66c9314ef6",
      "type" : "custom(257)"
    }
  }
}
len : 543
p_len : 543
 oid : 4
@ generate_schema_message: frameId=3
obj_tracking_id : 4
{
  "version" : "Nov 21 2022 06:03:10",
  "timestamp" : 20221121060326389,
  "id" : 3,
  "sensorId" : 0,
  "object" : {
    "id" : 4,
    "type" : "car",
    "bbox" : [
      708,
      0,
      1211,
      1077
    ],
    "attributes" : {
      "car" : 0.9611087441444397,
      "color" : 0.0,
      "model" : 0.0
    },
    "event" : {
      "id" : "d069029b-6b82-420f-b5c1-38f62395b07d",
      "type" : "custom(257)"
    }
  }
}
len : 431
p_len : 431
 oid : 3
@ generate_schema_message: frameId=3
obj_tracking_id : 3
{
  "version" : "Nov 21 2022 06:03:10",
  "timestamp" : 20221121060326389,
  "id" : 3,
  "sensorId" : 0,
  "object" : {
    "id" : 3,
    "type" : "car",
    "bbox" : [
      619,
      494,
      101,
      78
    ],
    "attributes" : {
      "car" : 0.87681102752685547,
      "color" : 0.0,
      "model" : 0.0
    },
    "event" : {
      "id" : "10494c86-d474-42a7-8af4-605e709b76fb",
      "type" : "custom(257)"
    }
  }
}
len : 431
p_len : 431
 oid : 2
@ generate_schema_message: frameId=3
obj_tracking_id : 2
{
  "version" : "Nov 21 2022 06:03:10",
  "timestamp" : 20221121060326389,
  "id" : 3,
  "sensorId" : 0,
  "object" : {
    "id" : 2,
    "type" : "car",
    "bbox" : [
      544,
      476,
      56,
      44
    ],
    "attributes" : {
      "car" : 0.7517927885055542,
      "color" : 0.0,
      "model" : 0.0
    },
    "event" : {
      "id" : "9d139cf6-02cd-4ac9-9326-f7480a9a560c",
      "type" : "custom(257)"
    }
  }
}
len : 429
p_len : 429
 oid : 1
@ generate_schema_message: frameId=3
obj_tracking_id : 1
{
  "version" : "Nov 21 2022 06:03:10",
  "timestamp" : 20221121060326389,
  "id" : 3,
  "sensorId" : 0,
  "object" : {
    "id" : 1,
    "type" : "car",
    "bbox" : [
      592,
      483,
      63,
      49
    ],
    "attributes" : {
      "car" : 0.57813525199890137,
      "color" : 0.0,
      "model" : 0.0
    },
    "event" : {
      "id" : "bb4fb9cf-46df-4b25-9e1c-9ce8541cb546",
      "type" : "custom(257)"
    }
  }
}
len : 430
p_len : 430
 oid : 0
@ generate_schema_message: frameId=3
obj_tracking_id : 0
{
  "version" : "Nov 21 2022 06:03:10",
  "timestamp" : 19700101000000000,
  "id" : 3,
  "sensorId" : 0,
  "object" : {
    "id" : 0,
    "type" : "car",
    "bbox" : [
      513,
      457,
      41,
      25
    ],
    "attributes" : {
      "car" : 0.38462930917739868,
      "color" : 0.0,
      "model" : 0.0
    },
    "event" : {
      "id" : "75a4ef82-1b8a-46ef-8f5b-95a736eeb215",
      "type" : "custom(257)"
    }
  }
}

I want to know how to set “nvds_msg2p_generate_multiple”

I want to use “nvds_msg2p_generate_multiple” function

What do I need to set up?(config file, code …)

you can use multiple-payloads property of nvmsgconv, please refer to https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_plugin_gst-nvmsgconv.html

tank you
I resolved!!

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