Convert frame from NvBufSurface (Deepstream 6.4) to VPIImage (VPI3.0)

**• Hardware Platform (Jetson / GPU) - GPU
• DeepStream Version 6.4
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only) 12.2 CUDA, Driver Version: 510.60.02
**. VPI Version: 3.0
**• Issue Type:

I want to transfer my GPU frame buffer from NvBufSurface to VPIImage directly (without bringing it down to CPU)

Eg:

        NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);                                                                                                                                                                                                      
        int _id = frame_meta->batch_id;                                                                                                                                                                                                                                     
        uint32_t width = surface->surfaceList[_id].width;                                                                                                                                                                                                                   
        uint32_t height = surface->surfaceList[_id].height;                                                                                                                                                                                                                 
        uint32_t pitch = surface->surfaceList[_id].pitch;                                                                                                                                                                                                                   
        uint32_t _size = surface->surfaceList[_id].dataSize;                                                                                                                                                                                                                
        NvBufSurfaceColorFormat fmt = surface->surfaceList[_id].colorFormat;                                                                                                                                                                                                
        void *cudaPtr = surface->surfaceList[_id].dataPtr;                                                                                                                                                                                                                  
        NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);                                                                                                                                                                                                      
        int _id = frame_meta->batch_id;                                                                                                                                                                                                                                     
        uint32_t width = surface->surfaceList[_id].width;                                                                                                                                                                                                                   
        uint32_t height = surface->surfaceList[_id].height;                                                                                                                                                                                                                 
        uint32_t pitch = surface->surfaceList[_id].pitch;                                                                                                                                                                                                                   
        uint32_t _size = surface->surfaceList[_id].dataSize;                                                                                                                                                                                                                
        NvBufSurfaceColorFormat fmt = surface->surfaceList[_id].colorFormat;                                                                                                                                                                                                
        void *cudaPtr = surface->surfaceList[_id].dataPtr;                                                                                                                                                                                                                  

        // This causes Seg Fault.
        cudaError_t cudaErr = cudaMemcpy2D (&vpiImage, pitch, cudaPtr, pitch, pitch, height, cudaMemcpyDeviceToHost);                                                                                                                                                       

Am I doing something wrong here?

What is the correct way of performing this since there is no existing wrapper function in VPI for this.

Hi,

Please find below page for some info:

https://elinux.org/Jetson/L4T/TRT_Customized_Example#VPI

Thanks

Hi

I have gone through this earlier, however it used a function called vpiImageCreateCUDAMemWrapper which is discontinued in VPI3.0.
Can you share me if there is any API available to do this or any other way of converting it. It will be of great help.

Thanks

Hi,

From VPI 2.x, we integrate all the wrappers into vpiImageCreateWrapper().
Please find the API below:

https://docs.nvidia.com/vpi/group__VPI__Image.html#ga3e7cf2520dd568a7e7a9a6876ea7995c

VPI_IMAGE_BUFFER_CUDA_PITCH_LINEAR | VPI_BACKEND_CUDA

Thanks.

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks