Deepstream 5.0 Python manipulation of frame data

Is it possible to manipulate Deepstream pipeline frame buffer data using the python bindings (for example using opencv in python to add circles to the frame)?

If so, is there documentation or any reference examples for this?

DeepStream python has provided some python binding to manipulate NvBufSurface:
( and

There is some simple sample of how to get NvBufSurface and use opencv to convert the video to jpeg image in deepstream-imagedata-multistream sample.

Thanks for the reply Fiona.

So if I understand correctly, I would use pyds.get_nvds_buf_surface() to get the frame data, and pyds.NvBufSurfaceCreate() to insert the modified frame data back into the pipeline?

If I wanted to overlay an image over detected objects before on-screen display for example, would I need to do this with a custom plugin or is a pad probe function (that utilises the two functions above and some opencv code) sufficient?

If the transformation will change the frame format, resolution or other capabilities, it should be done within a plugin. In pad probe, there is a lot of limitations.

pyds.NvBufSurfaceCreate() is to created a new NvBufSurface, I don’t think there is binding for attaching NvBufSurface to GstBuffer currently.