How to modify frame buffer returned by `pyds.get_nvds_buf_surface`?

• Hardware Platform (Jetson / GPU): Jetson Nano
• DeepStream Version: 5.01
• JetPack Version (valid for Jetson only): 4.4
• TensorRT Version: N/A
• NVIDIA GPU Driver Version (valid for GPU only): N/A
• Issue Type( questions, new requirements, bugs): questions

By looking at the deepstream-imagedata-multistream sample, I am able to retrieve a frame image as an numpy.ndarray object using pyds.get_nvds_buf_surface().
Now I want to do some calculation on it and modify the output buffer.
It seems modifying the ndarray in place does not work.

How can I achieve that?
Thank you.

1 Like

You need to use NvBufSurfaceSyncForDevice() to put the modified array back.

Thanks. How can I retrieve a NvBufSurface pointer, which is expected as an argument to NvBufSurfaceSyncForDevice()?

Seems it is not suitable to use pyds.get_nvds_buf_surface() which is a integrated interface.

You can refer to the C/C++ sample Deepstream sample code snippet, and try to translate them into python.

The available python bindings of pyds can be found Deepstream Python API Reference — Deepstream Deepstream Version: 6.1.1 documentation

How can I configure pyds.NvBufSurfaceCreateParams in Python as in the C++ code?
It seems its properties are read-only.

Traceback (most recent call last):
  File "run.py", line 394, in test_probe
    params.gpuId = 0
AttributeError: can't set attribute

We don’t have such bindings. You can modify the input buffer directly without the intermediate buffer then you don’t need the pyds.NvBufSurfaceCreateParams.

Could you give a bit more detail?
How can I retrieve the input buffer (pointer?) without using pyds.get_nvds_buf_surface()?

I checked again. We don’t have the related python bindings, seems it does not work.

OK. Thank you for clarification!