How to modified the frame image like nvvideoconvert but apply with other transform

Hello,

I would like to modify the frame image by transforming the image with some padding and crop to the main buffer gstreamer. This will be like implementing a custom nvvideoconvert.

Below are steps how I plan to do and I need help from Nvidia-er to correctly or guide.

  • get origin NvBufSurface from GstBuffer input data
  • allocate a new NvBufSurface with custom NvBufSurfaceCreateParams by NvBufSurfaceCreate and then do our transform convert data from input to output
  • release input data NvBufSurface by NvBufSurfaceDestroy and assign new NvBufSurface

Thank you for your help!!!

Hi,
We would suggest use dsexample plugin. Please check

/opt/nvidia/deepstream/deepstream-6.0/sources/gst-plugins/gst-dsexample/README

And an refer to the patches of calling NvBufSurface APIs:
How to create opencv gpumat from nvstream? - #18 by DaneLLL
Jetson Nano CSI Raspberry Pi Camera V2 upside down video when run an example with deepstream-app - #7 by DaneLLL

1 Like

Thank you @DaneLLL ,

I followed your suggest apply back to the original buffer with NvBufSurfTransform. but the result is not expected.

the output image still have size width height of origin image, it just copy modifed image into a part of it.

please help!

Hi,
The input/output resolution is not changed in dsexample plugin. For changing resolution, you would need to use nvvideoconvert to run like:

... ! nvvideoconvert ! nvdsexample ! ...

or

... ! nvdsexample !  nvvideoconver ! ...

You can configure the properties to cop the images:

  src-crop            : Pixel location left:top:width:height
                        Use string with values of crop location to set the prope
rty.
                         e.g. 20:20:40:50
                        flags: readable, writable, changeable only in NULL or RE
ADY state
                        String. Default: "0:0:0:0"
  dest-crop           : Pixel location left:top:width:height
                        Use string with values of crop location to set the prope
rty.
                         e.g. 20:20:40:50
                        flags: readable, writable, changeable only in NULL or RE
ADY state
                        String. Default: "0:0:0:0"
1 Like

Thank !! do you have any suggest to change the resolution but keep main tain aspect ration with nvvideoconvert?

Hi,
You may downscale/upscale to the resolution with identical aspect ratio. For example, if the source is in 1920x1080,you can downscale to 1280x720 or 630x360 to keep the resolution.

1 Like

hello @DaneLLL , Could I change the padding color into gray instead of the green color?

Hi,
Please try to call NvBufSurfTransformCompositeBlend(). You can set background color in NvBufSurfTransformCompositeBlendParams

1 Like

do you have any example code? thank you very much!!!

Hi,
We don’t have sample code for setting NvBufSurfTransformCompositeBlendParams and call NvBufSurfTransformCompositeBlend(). We will evaluate to add this in future release.

We have checked and discussed with our teams and confirms there is no existing code to change padding color to grey. One possible solution is to access the buffer and overwrite the region directly. You can call NvBufSurfaceMap() to get pointer to the buffer and overwrite the region.

There is sample of using NvBuffer APIs. Please refer to nvbuff_do_clearchroma() in

/usr/src/jetson_multimedia_api/samples/12_camera_v4l2_cuda/

Should be able to refer to it and replace NvBuffer APIs with NvBufSurface APIs, and try.

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