Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU) nano
• DeepStream Version 7.0
• JetPack Version (valid for Jetson only) 6.0
• TensorRT Version8.6.2.3-1+cuda12.2
• NVIDIA GPU Driver Version (valid for GPU only) NVIDIA-SMI 540.2.0
• Issue Type( questions, new requirements, bugs)
How to save face ROI ? In below code it return n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
RuntimeError: get_nvds_buf_Surface: Currently we only support RGBA color Format
def tracker_src_pad_buffer_probe(pad, info, user_data):
buf = info.get_buffer()
batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(buf))
gst_buffer = info.get_buffer()
if not gst_buffer:
print("Unable to get GstBuffer ")
return
# # Retrieve the caps of the pad to inspect the format
# caps = pad.get_current_caps()
# caps_structure = caps.get_structure(0)
# # Print the color format
# color_format = caps_structure.get_string("format")
# print(f"Buffer Color Format: {color_format}")
l_frame = batch_meta.frame_meta_list
while l_frame:
try:
frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
except StopIteration:
break
current_index = frame_meta.source_id
l_obj = frame_meta.obj_meta_list
while l_obj:
try:
obj_meta = pyds.NvDsObjectMeta.cast(l_obj.data)
except StopIteration:
break
parse_face_from_meta(frame_meta, obj_meta)
set_custom_bbox(obj_meta)
n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
# Get bounding box coordinates
# rect_params = obj_meta.rect_params
# top = max(int(rect_params.top), 0)
# left = max(int(rect_params.left), 0)
# width = max(int(rect_params.width), 0)
# height = max(int(rect_params.height), 0)
# Check if conditions are met for saving the frame
# if saved_count["stream_{}".format(frame_meta.pad_index)] % 30 == 0 and (
# MIN_CONFIDENCE < obj_meta.confidence < MAX_CONFIDENCE):
# if is_first_obj:
# is_first_obj = False
# Getting Image data using nvbufsurface
#n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
# Annotate the frame with bounding boxes
#n_frame = draw_bounding_boxes(n_frame, obj_meta, obj_meta.confidence)
# Convert python array into numpy array format
frame_copy = np.array(n_frame, copy=True, order='C')
# Convert the array into cv2 default color format
frame_copy = cv2.cvtColor(frame_copy, cv2.COLOR_RGBA2BGRA)
# # If Jetson, unmap the buffer after processing
# if platform_info.is_integrated_gpu():
# pyds.unmap_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
save_image = True
try:
l_obj = l_obj.next
except StopIteration:
break
img_path = "{}/stream_{}/frame_{}.jpg".format(folder_name, frame_meta.pad_index, frame_meta.frame_num)
# Create directory if it doesn't exist
os.makedirs(os.path.dirname(img_path), exist_ok=True)
# Save the image
#cv2.imwrite(img_path, frame_copy)
print(f"Saved image to {img_path}")
fps_streams['stream{0}'.format(current_index)].get_fps()
try:
l_frame = l_frame.next
except StopIteration:
break
return Gst.PadProbeReturn.OK