Correct way to add new object in frame meta in deepstream python

System:
Jetson AGX Xavier
Python 3.6
Jetpack 4.4.1
TRT 7.1.3
Deepstream 5.0.1

Hello. I’m trying to add new object to frame meta in deepstream python.

Code is below.

Summary

pyds.nvds_acquire_meta_lock(batch_meta)
new_object = add_object(batch_meta, frame_meta)
pyds.nvds_add_obj_meta_to_frame(frame_meta, new_object, None)
pyds.nvds_release_meta_lock(batch_meta)

Where
batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(gst_buffer))
frame_meta = frame_meta = pyds.NvDsFrameMeta.cast(frame_list.data)

In add_object i set up new_object params.

Summary

def add_object(batch_meta, frame_meta):

new_object = pyds.nvds_acquire_obj_meta_from_pool(batch_meta)
new_object.unique_component_id = 1
new_object.class_id = 3
new_object.confidence = 1.0
new_object.obj_label = 'new_object'
new_object.parent = None
new_object.rect_params.top = 0.0
new_object.rect_params.left = 0.0
new_object.rect_params.width = 800.0
new_object.rect_params.height = 600.0

return new_object

It works without errors, but after this probe there is classifier, that operates on class_id = 3, and as output from this classifier i always get same result. Always same label and confidence.

What is correct way to add new object? What is unique_component_id? As i saw in outputs, unique_component_id is always 1.

The code looks good.

unique_component_id is just the gie id, you set it in the config file gie-unique-id refer Gst-nvinfer — DeepStream 6.3 Release documentation

At first i added object of already existed class, but now tried to add new non-existed class. Problem with classifier results being added to meta of other detector’s classes is gone, but anyway there is always same output from sgie. Always same label and confidence.
Also i see object_id and detector_bbox_info params. As i know, object_id is for tracker, and what is NvDsComp_BboxInfo class?

I think you need to refer MetaData in the DeepStream SDK — DeepStream 6.3 Release documentation

Anyway, any ideas why code doesn’t work as expected?

Can you explain more details about your issue?

Sgie, that works on my newly added object, always returns same result for every frame on video. So object is changing, but sgie result is not.

What is your pipeline?

filesrc → h264decoder → decoder → streammux → pgie1 → (here i add new object with probe1) → sgie1 → sgie2 → (probe2) → fakesink

All models works fine, i get wrong results only on objects added in probe1. In probe2 i iterate over all frames and get models results.

You can add some debug info on the gstnvinfer.cpp → gst_nvinfer_process_objects or just run the app with gdb and add the breakpoint in the funciton , I think it should be easy for you to find the root cause.