I’m currently performing perspective transform using OpenCV on the CPU in my Deepstream pipeline.
For performance reasons, I would like to run this workload on the VIC but I have some issues on how to access the buffer and perform the memory wrapping in my GStreamer plugin.
This is the relevant function:
static GstFlowReturn
perspective_transform_frame (GstPerTransform * pertransform, gint idx, NvBufSurface * surface)
{
VPIPerspectiveTransform h =
{ { -0.9279668665637102, -1.2386680438837496, 1896.3056318819054 }, { -3.1888425618778356e-15, -2.068658617300784, 1667.6913395776087 }, { -2.1742384124008588e-18, -0.0013187187869792788, 1.0} };
VPIPayload vic_warp;
CHECK_VPI_STATUS(vpiCreatePerspectiveWarp(VPI_BACKEND_VIC, &vic_warp));
VPIImageData img_data;
VPIImageFormat type = VPI_IMAGE_FORMAT_NV12;
VPIImage img = NULL;
memset(&img_data, 0, sizeof(img_data));
img_data.type = type;
img_data.numPlanes = 1;
img_data.planes[0].width = surface->surfaceList[idx].planeParams.width[0];
img_data.planes[0].height = surface->surfaceList[idx].planeParams.height[0];
img_data.planes[0].pitchBytes = surface->surfaceList[idx].planeParams.pitch[0];
img_data.planes[0].data = surface->surfaceList[idx].mappedAddr.addr[0];
CHECK_VPI_STATUS(vpiImageCreateCudaMemWrapper(&img_data, 0, &img));
CHECK_VPI_STATUS(vpiSubmitPerspectiveWarp(pertransform->stream_vic, vic_warp, img, h, img, VPI_INTERP_LINEAR, VPI_BOUNDARY_COND_ZERO, ALREADY_INVERSE));
g_print(“done\n”);
return GST_FLOW_OK;
}
I get the error
terminate called after throwing an instance of ‘std::runtime_error’
what(): VPI_ERROR_INVALID_ARGUMENT
in the vpiImageCreateCudaMemWrapper function.
Could you elaborate on how to wrap the unified memory on the AGX Xavier so I can perform my workload on the VIC?
My pipeline: filesrc location=train_4.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvideoconvert ! pertransform ! nvinfer config-file-path= config_infer_primary.txt ! appsink name=appsink " *
** "emit-signals=True*
Environment
TensorRT Version : 7.1.3
GPU Type : agx xavier
CUDA Version : 10.2
CUDNN Version : 8.0
Operating System + Version : Ubuntu 18.04
Baremetal or Container (if container which image + tag) : baremetal