Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version 6.2
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)
The code structure is roughly like this
I want to blur each object with opencv through the pyarray received through get_nvds_buf_surface.
A segfault message appears as if the memory access was incorrect. (Uncomment line # frame_copy = cv2.cvtColor(image_array, cv2.COLOR_RGBA2BGR))
How should I write the code?
I’ve looked at various examples, but I can’t figure out how to approach it.
def blur_obj_pad_buffer_probe(buffer, user_data):
# 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(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 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:
break
# image_array: RGBA
image_array = pyds.get_nvds_buf_surface(buffer, frame_meta.batch_id)
# frame_copy = cv2.cvtColor(image_array, cv2.COLOR_RGBA2BGR)
l_obj = frame_meta.obj_meta_list
while l_obj is not None:
try:
# Casting l_obj.data to pyds.NvDsObjectMeta
obj_meta = pyds.NvDsObjectMeta.cast(l_obj.data)
except StopIteration:
break
# crop image
x1 = int(obj_meta.rect_params.left)
y1 = int(obj_meta.rect_params.top)
x2 = int(obj_meta.rect_params.left + obj_meta.rect_params.width)
y2 = int(obj_meta.rect_params.top + obj_meta.rect_params.height)
try:
l_obj = l_obj.next
except StopIteration:
break
if is_aarch64(): # If Jetson, since the buffer is mapped to CPU for retrieval, it must also be unmapped
pyds.unmap_nvds_buf_surface(buffer, frame_meta.batch_id) # The unmap call should be made after operations with the original array are complete.
# The original array cannot be accessed after this call.
try:
l_frame = l_frame.next
except StopIteration:
break
return DSL_PAD_PROBE_OK
Thank you