Hi, I would like to extract the time that the tracked object is in frame. Currently I am using the Deepstream_test_3 and Deepstream_test_2 for pulling and tracking object via the rtsp stream from an IP Camera. Would anyone be able to recommend the approach?
# tiler_sink_pad_buffer_probe will extract metadata received on OSD sink pad
# and update params for drawing rectangle, object information etc.
def tiler_src_pad_buffer_probe(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
# 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)
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.glist_get_nvds_frame_meta()
# 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.glist_get_nvds_frame_meta(l_frame.data)
except StopIteration:
break
'''
print("Frame Number is ", frame_meta.frame_num)
print("Source id is ", frame_meta.source_id)
print("Batch id is ", frame_meta.batch_id)
print("Source Frame Width ", frame_meta.source_frame_width)
print("Source Frame Height ", frame_meta.source_frame_height)
print("Num object meta ", frame_meta.num_obj_meta)
'''
frame_number=frame_meta.frame_num
l_obj=frame_meta.obj_meta_list
num_rects = frame_meta.num_obj_meta
obj_counter = {
PGIE_CLASS_ID_VEHICLE:0,
PGIE_CLASS_ID_PERSON:0,
PGIE_CLASS_ID_BICYCLE:0,
PGIE_CLASS_ID_ROADSIGN:0
}
while l_obj is not None:
try:
# Casting l_obj.data to pyds.NvDsObjectMeta
obj_meta=pyds.glist_get_nvds_object_meta(l_obj.data)
except StopIteration:
break
obj_counter[obj_meta.class_id] += 1
try:
l_obj=l_obj.next
except StopIteration:
break
display_meta=pyds.nvds_acquire_display_meta_from_pool(batch_meta)
display_meta.num_labels = 1
py_nvosd_text_params = display_meta.text_params[0]
py_nvosd_text_params.display_text = "Frame Number={} Number of Objects={} Vehicle_count={} Person_count={}".format(frame_number, num_rects, obj_counter[PGIE_CLASS_ID_VEHICLE], obj_counter[PGIE_CLASS_ID_PERSON])
py_nvosd_text_params.x_offset = 10;
py_nvosd_text_params.y_offset = 12;
py_nvosd_text_params.font_params.font_name = "Serif"
py_nvosd_text_params.font_params.font_size = 10
py_nvosd_text_params.font_params.font_color.red = 1.0
py_nvosd_text_params.font_params.font_color.green = 1.0
py_nvosd_text_params.font_params.font_color.blue = 1.0
py_nvosd_text_params.font_params.font_color.alpha = 1.0
py_nvosd_text_params.set_bg_clr = 1
py_nvosd_text_params.text_bg_clr.red = 0.0
py_nvosd_text_params.text_bg_clr.green = 0.0
py_nvosd_text_params.text_bg_clr.blue = 0.0
py_nvosd_text_params.text_bg_clr.alpha = 1.0
#print("Frame Number=", frame_number, "Number of Objects=",num_rects,"Vehicle_count=",vehicle_count,"Person_count=",person)
pyds.nvds_add_display_meta_to_frame(frame_meta, display_meta)
print("Frame Number=", frame_number, "Number of Objects=",num_rects,"Vehicle_count=",obj_counter[PGIE_CLASS_ID_VEHICLE],"Person_count=",obj_counter[PGIE_CLASS_ID_PERSON])
# Get frame rate through this probe
fps_streams["stream{0}".format(frame_meta.pad_index)].get_fps()
try:
l_frame=l_frame.next
except StopIteration:
break
return Gst.PadProbeReturn.OK
I’m think it will have to extract with this probe, but I don’t know what meta data to call/how to display the time elapsed from the original frame the object was detected.