How to assing custom source-id to buffers?

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version 6.2
• TensorRT Version 8.5.2
• NVIDIA GPU Driver Version (valid for GPU only) 530.30.02
• Issue Type( questions, new requirements, bugs)

In main config file, I have multiple sources:

[source0]
enable=0
...

[source1]
enable=1
...

[source2]
enable=1
...

source0 is not enabled, source1 and source2 are, but they get assigned source-id 0 and 1, respectively, instead of 1 and 2, as I would expect (as is in the source group name, for example [source1]).

I tried to utilize the camera-id component, but it does not work at all.
I then tried to add some custom code in deepstream_source_bin.c (function create_multi_source_bin()):

    if (useCameraIds)
    {
      bin->sub_bins[i].bin_id = bin->sub_bins[i].source_id = configs[i].camera_id;
      configs[i].source_id = configs[i].camera_id;
    }
    else
      bin->sub_bins[i].bin_id = bin->sub_bins[i].source_id = i;

And even though bin and config components now have source_id set as camera-id, when I get the NvDsFrameMeta.source_id variable in gstdsexample.cpp, these changes somehow do not persist.

I assume I am missing the part of the code, where NvDsFrameMeta gets its source_id assigned (maybe it’s not open-source).
How would you recommend to utilize the camera-id parameter, to be able to read its value in a buffer in gstdsexample.cpp?

why do you need to customize source_id? which sample are you referring to? what is the main media pipeline?

why do you need to customize source_id?

I need to maintain the order of the cameras source_id when i set some sources to enable=0. I have a configuration file with 15 sources, but sometimes not all of them are enabled, when that happens, the original source_id order gets mixed up. I have a consumer application that uses data processed from Deepstream, so the source_id order is really important.

which sample are you referring to?

I am using deepstream-app

what is the main media pipeline?

source → streammux → preprocess → pgie → tracker → sgie → dsexample

Any idea regarding why my code change (assigning source_id as camera_id) did not get assigned toNvDsFrameMeta later in the pipeline? Or, perhaps, any thoughts on how I could achieve this?

deepstream-app is opensource. you can customize it. if you are testing local files, deepstream-app will use uridecodebin plugin. framemeta’s source_id is set in nvstreammux plugin.
here is a solution:

  1. you can set source_id=1 in [source1] and source_id=2 in [source2] . deepstream-app will save it to NvDsSourceConfig, which is also one parameter of create_multi_source_bin. then modify
    if (!link_element_to_streammux_sink_pad (bin->streammux,
    bin->sub_bins[i].bin, i))
    to
    if (!link_element_to_streammux_sink_pad (bin->streammux,
    bin->sub_bins[i].bin, configs[i].source_id))
  2. rebuild deepsream-app. if you add a probe on nvstreammux’s src pad, you will find framemeta’s source_id is 1or 2.

Thank you, this worked.

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