How to save frame from pipeline using OpenCV on GPU?

• Hardware Platform: GPU
• DeepStream Version: 7.1
• NVIDIA GPU Driver Version: 560
• Issue Type: question

Hello, I am trying to save photos of detected cars into a storage, but unfortunately i ran into an issue. The problem is that i need to get the frame and then crop it and save it and when I do that, the app crashes (exit code -11). I have tried setting the NVBUF_MEMORY_TYPE to 3, but this doesn’t do anything. How to solve this issue and save the image? I have also tried the same code on the Jetson ORIN NX and the code worked flawlessly. So there is some issue just on the GPU platform.

Here is the code I am using for saving the image:

gst_buffer = info.get_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:
    frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
    frame_surface = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
    frame_rgba = np.array(frame_surface, copy=True, order="C")
    frame_bgr = cv2.cvtColor(frame_rgba, cv2.COLOR_RGBA2BGR)
    filename = "image.jpg"
    cv2.imwrite(filename, frame_bgr)
4 Likes

Please refer to the ready-made sample deepstream_imagedata-multistream.py for dumping frames.

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.