Hi, I am trying to adding to add my own NvDsObjectMeta data to the buffer in Python as I am using an external, non TRT model.
In my pipeline I have the following elements (in the order of linking)
uridecodebin
streamux
nvvidconv
filter
tracker
sink
I have a probe at the sink pad of the filter. Using the following code I am able to extract the decoded frame from the pipeline inside that probe function:
def filter1_sink_pad_buffer_probe(self, pad, info, u_data):
frame_number = 0
num_rects = 0
gst_buffer = info.get_buffer()
if not gst_buffer:
print("Unable to get GstBuffer ")
return
batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(gst_buffer))
l_frame = batch_meta.frame_meta_list
while l_frame is not None:
try:
# Note that l_frame.data needs a cast to pyds.NvDsFrameMeta
# The casting is done by pyds.NvDsFrameMeta.cast()
# The casting also keeps ownership of the underlying memory
# in the C code, so the Python garbage collector will leave
# it alone.
frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
except StopIteration:
print("returning")
return
# Retrieve batch metadata from the gst_buffer
# Note that pyds.gst_buffer_get_nvds_batch_meta() expects the
# C address of gst_buffer as input, which is obtained with hash(gst_buffer)]
frame_number = frame_meta.frame_num
# NVINFER ELEMENT PRODUCES BATCH DATA OF TYPE NVDS_META_FRAME_INFO
# THE FUNCTION BELOW SUPPORTS RGBA FORMAT ONLY!!!
n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
# convert python array into numpy array format.
self.out_image = np.array(n_frame, copy=True, order='C')
This image then gets sent to an inference engine and I receive the detection results (bbox x,y,w,h confidence and class_id). Now, I fill in the NvDsObjectMeta for each object inside the same probe function:
pyds.nvds_acquire_meta_lock(batch_meta)
frame_meta.bInferDone = True
obj_meta = pyds.nvds_acquire_obj_meta_from_pool(batch_meta)
obj_meta.rect_params.top = y - (h / 2)
obj_meta.rect_params.left = x - (w / 2)
obj_meta.rect_params.width = w
obj_meta.rect_params.height = h
obj_meta.parent = None
obj_meta.confidence = confidence
obj_meta.class_id = class_id
UNTRACKED_OBJ_ID = 0xFFFFFFFFFFFFFFFF
obj_meta.object_id = UNTRACKED_OBJ_ID
obj_meta.unique_component_id = 1
pyds.nvds_add_obj_meta_to_frame(frame_meta, obj_meta, None)
pyds.nvds_release_meta_lock(batch_meta)
Now when I run my code, everything works fine but it seems like the tracker isn’t updating the NvDsObjectMeta data with updating bbox params? What am I missing?
When I add a probe to the sink of the tracker and print object ID’s I get:
trackingId = long_to_int(obj_meta.object_id)
print("TRACKING ID AT TRACKER SINK IS {}".format(trackingId))
**-1**
The tracking ID never changes from -1 for any object. Am I supposed to increment this number in my filter probe function or should NvTracker do this?
Thanks
• Hardware Platform GPU - RTX2060 Super
• DeepStream Version - 5
• NVIDIA GPU Driver Version - 440.64