Write custom gstreamer plugin in python and use tin deepstream

Hi,

Q1- Suppose I create a pipeline and the last pipeline produce with caps : video/x-raw(memory:NVMM) and I want to create a custom plugin and perform some processing on nvidia jetson devices. This need to do processing in GPU buffer? Is it possible to convert buffers to numpy? If it so, Is it optimal solution?

Q2- I create a class that inherited from GstBase.BaseTransform and has this method:

def do_transform_ip(self, buffer: Gst.Buffer) -> Gst.FlowReturn:
        // Do some processing on Buffer and metadata
        return Gst.FlowReturn.OK

My problem is that when I added this custom plugin to pipeline in deepstream, the pipeline doesn’t any work but doesn’t throw any error, Is it possible to use custom plugin in deepstream pipeline along with deepstream plugin?

Hi,

It is possible to convert buffers to numpy, but it is not an optimal solution.

We have dsexample as custom gstreamer plugin, but it is only for C/C++ and cannot be applied to python.

1 Like

Yes, but it’s slow. As DaneLLL says, it’s better to modify gst-dsexample, compile that, and you can use the resulting plugin in Python. (or any language that supports GStreamer). You don’t have to write everything in C, but when it comes to custom elements, you really need at least some C/C++/Rust/Vala.

@mdegans, @DaneLLL

Thanks

@mdegans, @DaneLLL

Hi dears,
I write a custom plugin gstreamer in python and used pyds for modification metadata, my plugin is doing inference model , like this:

def do_transform_ip(self, buffer: Gst.Buffer) -> Gst.FlowReturn:
        /* load model */
        model(x)
        return Gst.FlowReturn.OK

One solution is to convert buffer to numpy array and then pass ndarray to model, but How I can to pass buffer without numpy array conversation and pass to model?

Hi,
You may try to link like

... ! dsexample ! nvinfer ! ...

And implement a custom dsexample.