It is difficult to work with NVIDIA due to its vague information. I figured out the solution reading the bindings. I share the source code (based on Deepstream_test2.py) to someone else that have the same issue in the future:
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:
frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
except StopIteration:
break
frame_number=frame_meta.frame_num
num_rects = frame_meta.num_obj_meta
l_obj=frame_meta.obj_meta_list
while l_obj is not None:
try:
obj_meta=pyds.NvDsObjectMeta.cast(l_obj.data)
except StopIteration:
break
class_obj=obj_meta.classifier_meta_list
while class_obj is not None:
try:
class_meta=pyds.NvDsClassifierMeta.cast(class_obj.data)
except StopIteration:
break
c_obj=class_meta.label_info_list
while c_obj is not None:
try:
c_meta=pyds.NvDsLabelInfo.cast(c_obj.data)
except StopIteration:
break
print(c_meta.result_label)
try:
c_obj=c_obj.next
except StopIteration:
break
try:
class_obj=class_obj.next
except StopIteration:
break
obj_counter[obj_meta.class_id] += 1
try:
l_obj=l_obj.next
except StopIteration:
break