Differentiate source of frame for multiple sources application

I am testing deepstream-app with 6 sources.
Inside deepstream_app.c and in the following source code, we can see the frame meta and object meta.

When I print g_print ("frame source: %d \n",frame_meta->source_id);, I have source id is 0 always.
How can I know the source id of the frame so that I know the frame and camera id (source id)?

for (NvDsMetaList * l_frame = batch_meta->frame_meta_list; l_frame != NULL;
      l_frame = l_frame->next) {    
    NvDsFrameMeta *frame_meta = l_frame->data;
    g_print ("frame source: %d \n",frame_meta->source_id);
    for (NvDsMetaList * l_obj = frame_meta->obj_meta_list; l_obj != NULL;
        l_obj = l_obj->next) {
      NvDsObjectMeta *obj = (NvDsObjectMeta *) l_obj->data;
      //g_print ("object: %ld \n",obj->object_id);
      gint class_index = obj->class_id;
      NvDsGieConfig *gie_config = NULL;
      gchar *str_ins_pos = NULL;

I printed as follow

static void
process_meta (AppCtx * appCtx, NvDsBatchMeta * batch_meta)
{
  // For single source always display text either with demuxer or with tiler
  if (!appCtx->config.tiled_display_config.enable ||
      appCtx->config.num_source_sub_bins == 1) {
    appCtx->show_bbox_text = 1;
  }
  for (NvDsMetaList * l_frame = batch_meta->frame_meta_list; l_frame != NULL;
      l_frame = l_frame->next) {    
    NvDsFrameMeta *frame_meta = l_frame->data;
    g_print ("source_id batch_id surface_type surface_index : %d %d %d %d\n",frame_meta->source_id,frame_meta->batch_id,frame_meta->surface_type,frame_meta->surface_index);

I got all 0.

source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0
source_id batch_id surface_type surface_index : 0 0 0 0

Eventhough I have 6 sources, I don’t know which frame is from which source?

There are discussions here from @ cclaunch and a few others. They also discussed how to get source id for frames in multiple sources processing a few days ago.

For me I used deepstream-test3 program and I can have source id from probing in that program.

When I have time I’ll go back to deepstream-app as it has a lot stuffs to understand more about deepstream plugins.

What is the platform and version information for your test? Jetson or DGPU? Deepstream 4.0 or Deepstream 5.0? What is your configuration with deepstream-app? Where has you put the “process_meta” to?

Mine are Deepstream 5.0 and AGX Xaiver.

What is your configuration with deepstream-app? Where has you put the “process_meta” to?

deepstream_app_source1_peoplenet.txt and config_infer_primary_peoplenet.txt using peoplenet from tlt.
I am not sure about “process_meta” you are asking.
I just probe from process_meta from deepstream-app and print as g_print ("source_id batch_id surface_type surface_index : %d %d %d %d\n",frame_meta->source_id,frame_meta->batch_id,frame_meta->surface_type,frame_meta->surface_index);

static void
process_meta (AppCtx * appCtx, NvDsBatchMeta * batch_meta)
{
  // For single source always display text either with demuxer or with tiler
  if (!appCtx->config.tiled_display_config.enable ||
      appCtx->config.num_source_sub_bins == 1) {
    appCtx->show_bbox_text = 1;
  }
  for (NvDsMetaList * l_frame = batch_meta->frame_meta_list; l_frame != NULL;
      l_frame = l_frame->next) {    
    NvDsFrameMeta *frame_meta = l_frame->data;
    g_print ("source_id batch_id surface_type surface_index : %d %d %d %d\n",frame_meta->source_id,frame_meta->batch_id,frame_meta->surface_type,frame_meta->surface_index);
    for (NvDsMetaList * l_obj = frame_meta->obj_meta_list; l_obj != NULL;
        l_obj = l_obj->next) {
      NvDsObjectMeta *obj = (NvDsObjectMeta *) l_obj->data;
      g_print ("left top width height : %f %f %f %f\n",obj->rect_params.left,obj->rect_params.top,obj->rect_params.width,obj->rect_params.height); 
      gint class_index = obj->class_id;
      NvDsGieConfig *gie_config = NULL;
      gchar *str_ins_pos = NULL;

What is deepstream_app_source1_peoplenet.txt? Can you upload it?

deepstream_app_source1_peoplenet.txt (3.3 KB)
config_infer_primary_peoplenet.txt (1.0 KB)

When using nvmultistreamtiler plugin in your pipeline, the multiple streams are merged to one stream. “process_meta” is probed after nvmultistreamtiler plugin, so it can only detect one stream.
Either disable nvmultistreamtiler or move “process_meta” before nvmultistreamtiler and after “nvstreammux”, you can get the separated stream id with “frame_meta->source_id”.

Thank you. It works

@Fiona.Chen
But nvstreammux is before pgie and how can I have source_id together with boxes? So that I know boxes and its frame source for further processing.

The object_list is inside frame_meta, that means these objects belong to this frame.

for (NvDsMetaList * l_frame = batch_meta->frame_meta_list; l_frame != NULL;
l_frame = l_frame->next) {
for (NvDsMetaList * l_obj = frame_meta->obj_meta_list; l_obj != NULL;
l_obj = l_obj->next) {
NvDsObjectMeta *obj = (NvDsObjectMeta *) l_obj->data;
obj->rect_params //bbox parameters
}
}
}

https://docs.nvidia.com/metropolis/deepstream/dev-guide/DeepStream_Development_Guide/baggage/group__metadata__structures.html

Thank you.