Buffer data Update/Overwrite. d

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) :- dGPU
• DeepStream Version :- 6.4

Is it possible to modify the buffer to draw something on that ??

I have used Buffer Surface Management API to obtain the buffer and then cv::mat and I drew whatever I wanted to draw on it. Now I want to overwrite the original buffer with the modified one ??

*It should get modified in a way that the next elements in the pipeline should see the modified buffer.

Note :- I do not have streammux in the pipeline, so I can not use osd element.

Is this possible ?

Yes if you don’t change the resolution and format of the video.

Are you working with c/c++ APIs or python APIs?

Which elements of DeepStream have you used in your pipeline? Can you show us the whole pipeline?

I have recreated my Pipeline with the deepstream-test3 app. Below is my pipeline graph.

I’m using C++ APIs.

I have a probe function at sink pad of caps filter of the non-streammux branch of the pipeline, wherein I use the Image in following way.

 static GstPadProbeReturn nvvidconv_src_pad_probe(GstPad *pad,
                                                 GstPadProbeInfo *info,
                                                 gpointer user_data) {
    SyncBuffer &sb = *static_cast<SyncBuffer *>(user_data);
    GstBuffer *buf = GST_PAD_PROBE_INFO_BUFFER(info);
    GstMapInfo map_info;

    if (gst_buffer_map(buf, &map_info, GST_MAP_READ)) {
        NvBufSurface *surface = (NvBufSurface *)map_info.data;
        // Map the buffer for CPU access
        NvBufSurfaceMap(surface, -1, -1, NVBUF_MAP_READ);
        // Synchronize the buffer for CPU access
        NvBufSurfaceSyncForCpu(surface, -1, -1);
        for (int i = 0; i < surface->numFilled; i++) {
            NvBufSurfaceParams *params = &surface->surfaceList[i];
            cv::Mat frame(params->height, params->width, CV_8UC3,
                          params->dataPtr, params->pitch);
           //do something with cv::mat 
           // then modify the original buffer or overwrite it. 
        }
        gst_buffer_unmap(buf, &map_info);
    }

    return GST_PAD_PROBE_OK;
}```

If you do not want to use GPU to process and replace the video content, it is no meaning to get the video data from NvBufSurface. You can probe in the sink pad of the avenc_mjpeg, the video is just a normal GstBuffer, you can change the content directly.

do you have any sample code of accessing the image data from gstbuffer ?

There are lots of samples in GStreamer. GstBuffer (gstreamer.freedesktop.org)

thanks

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