Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version 6.3
• JetPack Version (valid for Jetson only)
• TensorRT Version 8.5
• NVIDIA GPU Driver Version (valid for GPU only) 550.142
• Issue Type( questions, new requirements, bugs)
When I ran the deepstream pipeline with conda, no exception was found, when I packaged it with pyinstaller, and when my function pgie_src_pad_buffer_probe() was called, batch_meta = pyds.gst_buffer_get_nvds_batch_meta(gst_buffer.hash()) Error GStreamer-CRITICAL **: 16:10:55.658: gst_meta_api_type_has_tag: assertion ‘tag ! = 0’ failed and the batch_meta value is None
def pgie_src_pad_buffer_probe(self, pad, info, u_data):
frame_number = 0
num_rects = 0
got_fps = False
current_time = time.time()
# self.update_time = time.time()
gst_buffer = info.get_buffer()
if not gst_buffer:
MyLogger.error("Unable to get GstBuffer ")
return Gst.PadProbeReturn.OK
# opencv_image = StreamCapture.gst_buffer_to_opencv(gst_buffer)
# 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))
batch_meta = pyds.gst_buffer_get_nvds_batch_meta(gst_buffer.__hash__())
# batch_meta = None
# print(gst_buffer.__hash__())
#todo
if not batch_meta:
MyLogger.warning(f"Batch meta is None, skipping frame processing:{gst_buffer.__hash__()}")
return Gst.PadProbeReturn.OK
l_frame = batch_meta.frame_meta_list
while l_frame is not None:
n_frame1_box = 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)
# MyLogger.info(f"--------------------------------{frame_meta.batch_id}")
if current_time - self.last_alive_time_dict.setdefault(frame_meta.pad_index, 0) > 60 * 5:
MyLogger.info(f"source [{frame_meta.pad_index}]:{self.stream_path_code[frame_meta.pad_index]} is alive...")
self.last_alive_time_dict[frame_meta.pad_index] = current_time
if current_time - self.last_frame_time_dict.setdefault(frame_meta.pad_index, 0) < self.frame_interval:
return Gst.PadProbeReturn.OK
self.last_frame_time_dict[frame_meta.pad_index] = current_time
except StopIteration:
break
frame_number = frame_meta.frame_num
l_obj = frame_meta.obj_meta_list
num_rects = frame_meta.num_obj_meta
is_first_obj = True
save_image = False
obj_counter = {
PGIE_CLASS_ID_VEHICLE: 0,
PGIE_CLASS_ID_PERSON: 0,
PGIE_CLASS_ID_BICYCLE: 0,
PGIE_CLASS_ID_ROADSIGN: 0
}
# n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
n_frame = pyds.get_nvds_buf_surface(gst_buffer.__hash__(), frame_meta.batch_id)
n_frame1 = np.array(n_frame, copy=True, order='C')
while l_obj is not None:
try:
# Casting l_obj.data to pyds.NvDsObjectMeta
obj_meta = pyds.NvDsObjectMeta.cast(l_obj.data)
# print(obj_meta.class_id)
except StopIteration:
break
obj_counter[obj_meta.class_id] += 1
# if is_first_obj:
# is_first_obj = False
if n_frame1_box is None:
n_frame1_box = StreamCapture.draw_bounding_boxes(copy.deepcopy(n_frame1), obj_meta,
obj_meta.confidence)
else:
n_frame1_box = StreamCapture.draw_bounding_boxes(n_frame1_box, obj_meta,
obj_meta.confidence)
# convert python array into numpy array format in the copy mode.
try:
l_obj = l_obj.next
except StopIteration:
break
# convert the array into cv2 default color format
n_frame1 = cv2.cvtColor(n_frame1, cv2.COLOR_RGBA2RGB)
# n_frame1 = cv2.cvtColor(n_frame1, cv2.COLOR_RGBA2BGRA)
if n_frame1_box is not None:
cv2.imwrite(f"1-{frame_meta.batch_id}.jpg", n_frame1_box)
with self.lock:
self.frame_dict.setdefault(str(frame_meta.pad_index), {"frame": None, "time": None})
self.frame_dict[str(frame_meta.pad_index)]["frame"] = n_frame1
self.frame_dict[str(frame_meta.pad_index)]["time"] = get_current_timestamp_millis()
if not silent:
MyLogger.info(
f"batchid:{frame_meta.pad_index},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]}")
# Update frame rate through this probe
stream_index = "stream{0}".format(frame_meta.pad_index)
# global perf_data
# perf_data.update_fps(stream_index)
try:
l_frame = l_frame.next
except StopIteration:
break
return Gst.PadProbeReturn.OK
def _read_loop(self):
# global perf_data
# perf_data = PERF_DATA(len(self.stream_paths))
number_sources = len(self.stream_paths)
# Standard GStreamer initialization
# create an event loop and feed gstreamer bus mesages to it
self.bus = self.pipeline.get_bus()
# self.pgie_src_pad = self.tiler.get_static_pad("src")
self.pgie_src_pad = self.tiler.get_static_pad("sink")
if not self.pgie_src_pad:
MyLogger.error(" Unable to get src pad")
else:
if not self.disable_probe:
self.pgie_src_pad.add_probe(Gst.PadProbeType.BUFFER, self.pgie_src_pad_buffer_probe, 0)
# perf callback function to print fps every 5 sec
# GLib.timeout_add(5000, perf_data.perf_print_callback)
# List the sources
MyLogger.info("Now playing...")