Hi,
We have an example for EGL buffer → VPI → EGL buffer below:
https://forums.developer.nvidia.com/t/deepstream-sdk-vpi-on-jetson-tx2/166834/21
...
/* map inbuf -> EGL */
if (NvBufSurfaceMapEglImage (surface, -1) != 0) {
g_print ("Error: Could not map EglImage from NvBufSurface for dsexample\n");
goto error;
}
if (cuGraphicsEGLRegisterImage (&pResource,
surface->surfaceList[0].mappedAddr.eglImage,
CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE) != CUDA_SUCCESS) {
g_print ("Error: Failed to register EGLImage in cuda\n");
goto error;
}
if (cuGraphicsResourceGetMappedEglFrame (&eglFrame,
pResource, 0, 0) != CUDA_SUCCESS) {
g_print ("Error: Failed to get mapped EGL Frame\n");
goto error;
}
cuCtxSynchronize();
/* inter_buf -> VPI */
memset(&data, 0, sizeof(data));
data.format = VPI_IMAGE_FORMAT_RGBA8;
data.numPlanes = surface->surfaceList[0].planeParams.num_planes;
for(i=0; i<data.numPlanes; i++) {
data.planes[i].width = surface->surfaceList[0].planeParams.width[i];
data.planes[i].height = surface->surfaceList[0].planeParams.height[i];
data.planes[i].pitchBytes = surface->surfaceList[0].planeParams.pitch[i];
data.planes[i].data = eglFrame.frame.pPitch[i];
}
CHECK_VPI_STATUS(vpiImageCreateCUDAMemWrapper(&data, 0, &img));
CHECK_VPI_STATUS(vpiImageCreate(data.planes[0].width, data.planes[0].height, VPI_IMAGE_FORMAT_RGBA8, 0, &out));
...
/* Apply warping */
CHECK_VPI_STATUS(vpiSubmitConvertImageFormat(dsexample->vpi_stream, VPI_BACKEND_CUDA, img, out, NULL));
CHECK_VPI_STATUS(vpiSubmitPerspectiveWarp(dsexample->vpi_stream, 0, dsexample->warp, img, xform, out
, VPI_INTERP_LINEAR, VPI_BORDER_ZERO, 0));
CHECK_VPI_STATUS(vpiSubmitConvertImageFormat(dsexample->vpi_stream, VPI_BACKEND_CUDA, out, img, NULL));
CHECK_VPI_STATUS(vpiStreamSync(dsexample->vpi_stream));
...
Does this meet your requirement?
Or you prefer to wrap a VPI image with vpiImageCreateNvBufferWrapper?
Thanks.