Segmentation fault core dumped, deepstream 6.2

• Hardware Platform (t4 GPU)
• DeepStream Version 6.2

  • Ubuntu 20.04
  • GStreamer 1.16.3
  • NVIDIA driver 525.60.13
  • CUDA 11.8
  • TensorRT 8.5.1.7
    so basically im trying to access a frame from a video to write it and i ran it to a segmentation fault
def get_frame_from_gst_buffer(gst_buffer, batch_id,obj_meta):
    print(f"Entering get_frame_from_gst_buffer with batch_id: {batch_id}")
    
    if gst_buffer is None:
        print("gst_buffer is None")
        return None
    
    try:
        print(f"Calling get_nvds_buf_surface with hash(gst_buffer): {hash(gst_buffer)}")
        nvbufsurface = pyds.get_nvds_buf_surface(hash(gst_buffer), batch_id)
        print(f"nvbufsurface type: {type(nvbufsurface)}")
        
        if nvbufsurface is None:
            print("get_nvds_buf_surface returned None")
            return None
        
        print(f"nvbufsurface shape: {nvbufsurface.shape}, dtype: {nvbufsurface.dtype}")
        print(f"nvbufsurface memory info: {nvbufsurface.base}")
        
    except Exception as e:
        print(f"Exception in get_nvds_buf_surface: {e}")
        return None

    try:
        print("Attempting to create frame_copy")
        frame_copy = np.asarray(nvbufsurface, order='C')
        print(f"frame_copy shape: {frame_copy.shape}")
    except Exception as e:
        print(f"Exception in np.array: {e}")
        return None

    try:
        print("Attempting cv2.imencode")
        _, buffer = cv2.imencode('.jpg', frame_copy)
        print(f"Encoded buffer size: {len(buffer)}")
    except Exception as e:
        print(f"Exception in cv2.imencode: {e}")
        return None

    image_base64 = base64.b64encode(buffer).decode()
    print(f"base64 encoded image length: {len(image_base64)}")

    return image_base64

nvbufsurface type: <class ‘numpy.ndarray’>
nvbufsurface shape: (1080, 1920, 4), dtype: uint8
nvbufsurface memory info: <capsule object NULL at 0x7f1d09fd0960>
Attempting to create frame_copy
frame_copy shape: (1080, 1920, 4)
Attempting cv2.imencode
Segmentation fault (core dumped)
, can someone let me know why this is happening?

  1. Only RGBA format can be supported.

  2. Use CUDA unified memory in the pipeline so frames can be easily accessed on CPU in Python.

refer this sample deepstream_python_apps/apps/deepstream-imagedata-multistream/deepstream_imagedata-multistream.py at v1.1.6 · NVIDIA-AI-IOT/deepstream_python_apps · GitHub

Alright so i added

    caps1 = Gst.Caps.from_string("video/x-raw(memory:NVMM), format=RGBA")
    filter1 = Gst.ElementFactory.make("capsfilter", "filter1")
    if not filter1:
        sys.stderr.write(" Unable to get the caps filter1 \n")
    filter1.set_property("caps", caps1)
    mem_type = int(pyds.NVBUF_MEM_CUDA_UNIFIED)
    streammux.set_property("nvbuf-memory-type", mem_type)
        nvvideoconvert.set_property("nvbuf-memory-type", mem_type)
        nvvideoconvert2.set_property("nvbuf-memory-type", mem_type)
  
        # connect  queue -> nvvidconv -> nvosd -> nveglgl
        queue.link(nvvideoconvert)
        nvvideoconvert.link(filter1)
        filter1.link(nvdsosd)
        nvdsosd.link(nvvideoconvert2)
        nvvideoconvert2.link(capsfilter)
        capsfilter.link(encoder)
        encoder.link(codeparser)
        if args[i].split(".").pop() == "h264":
            codeparser.link(sink)
        else:
            codeparser.link(container)
            container.link(sink)

        sink.set_property("qos", 0)

like from the example app , now im facing this error
Error: gst-stream-error-quark: memory type configured and i/p buffer mismatch ip_surf 2 muxer 3 (1): gstnvstreammux.c(643): gst_nvstreammux_chain (): /GstPipeline:pipeline0/GstNvStreamMux:Stream-muxer
i’ll attach my entire code
DeepstreamError.txt (22.9 KB)

There are some issues with your pipeline, build the pipeline like below.

Is it mandatory to use mpeg4 encoding? Use hardware encoding to improve performance.

uridecodebin  --> nvstreammux --> gie -->nvvideoconvert --> capsfiller(NVMM:RGBA) --> nvosd --> nvsteamdemux --> nvvideoconvert --> cpafiller2(NVMM:NV12) --> nvv4l2h264enc --> mp4mux --> filesink
                                                         |
                                                 add probe for save_frame_image_as_base64

ah i’ll make those necessary changes for improved performance, but the above error was because i forgot to set object to cuda unified memory in the decodebin

def decodebin_child_added(child_proxy, Object, name, user_data):

    print("Decodebin child added:", name, "\n")
    if name.find("decodebin") != -1:
        Object.connect("child-added", decodebin_child_added, user_data)
    if name.find("nvv4l2decoder") != -1:
 
        Object.set_property("cudadec-memtype", 2)

    if "source" in name:
        source_element = child_proxy.get_by_name("source")
        if source_element.find_property("drop-on-latency") != None:
            Object.set_property("drop-on-latency", True)

Thank you for your assistance!

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