• Hardware Platform (Jetson / GPU) Jetson Xavie
• DeepStream Version 5.1
• Issue Type question
Hey there.
I am planning on implementing a custom deepstream plugin that does a perspective transformation on the frames in the buffer. After some research, I decided to use the VPI framework. I have started from the gstdsexample plugin and took hints from posts such as this one and this one. Here is the essential logic of my plugin’s transform_ip function:
...
NvBufSurfaceMap(input_buf, idx, 0, NVBUF_MAP_READ_WRITE);
// NvBufSurfaceSyncForCpu (input_buf, 0, 0);
guint src_width = GST_ROUND_UP_2((unsigned int)vpiwarp->video_info.width);
guint src_height = GST_ROUND_UP_2((unsigned int)(gint)vpiwarp->video_info.height);
VPIPerspectiveTransform h1={
{ 1.0, 0.0, 0.0 },
{ 0.0, 1.0, 100 },
{ 5, 1.2, 1.0 }
};
CHECK_VPI_STATUS(vpiCreatePerspectiveWarp(VPI_BACKEND_VIC, &vpiwarp->vic_warp));
VPIImage img = NULL;
VPIImageData img_data;
memset(&img_data, 0, sizeof(img_data));
img_data.format = VPI_IMAGE_FORMAT_RGBA8;
img_data.numPlanes = input_buf->surfaceList[idx].planeParams.num_planes;
img_data.planes[0].width = src_width;
img_data.planes[0].height = src_height;
img_data.planes[0].pitchBytes = input_buf->surfaceList[idx].planeParams.pitch[0];
img_data.planes[0].data = input_buf->surfaceList[idx].mappedAddr.addr[0];
CHECK_VPI_STATUS(vpiImageCreateHostMemWrapper(&img_data, 0, &img));
CHECK_VPI_STATUS(vpiSubmitPerspectiveWarp(vpiwarp->stream, VPI_BACKEND_VIC,vpiwarp->vic_warp, img, h1,
img, VPI_INTERP_LINEAR, VPI_BORDER_ZERO, 0));
vpiStreamSync(vpiwarp->stream);
NvBufSurfaceUnMap(input_buf, idx, 0);
vpiImageDestroy(img);
return GST_FLOW_OK;
Here is my pipeline:
gst-launch-1.0 uridecodebin uri=file:///opt/nvidia/deepstream/deepstream-5.1/samples/streams/sample_720p.h264 ! m.sink_0 \
nvstreammux name=m batch-size=1 width=1280 height=720 ! nvvideoconvert ! \
"video/x-raw(memory:NVMM),format=RGBA" ! vpiwarp ! nvvideoconvert ! \
x264enc ! filesink location=out.h264
I have two main concerns:
-
Let’s say my GPU will be busy in my original application for inference, and I want to use the VIC as the backend. What kind of Wrapper should I use for the most efficient VIC usage?
Should I use Host, CUDA (with EGL), or NvBuffer? Which one is fastest for using the VIC? -
Secondly, when I apply the transformation, I want it to replace the original frame in the buffer. I would like the next plugins to see the modified frame. But my current code doesn’t do that. the video file created by the sink element does not have the transformed frames!
One solution is of course to let go of the in-place plugin and have two buffers. But I want to know if I can avoid that (use in place plugin and change the frames in buffer with the VPI output).
Thank you for spending time on this.
Best.