cv::cuda::GpuMat data copyTo NvbufSurface failed

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) Jetson AGX Orin
• DeepStream Version 6.3
• JetPack Version (valid for Jetson only) Jetpack 5.1.2 [L4T 35.4.1]
• TensorRT Version 8.5.2
• Issue Type( questions, new requirements, bugs) bugs

This is my code,after execution, the buff fd does not change, I don’t know what the problem is, Thank you for your help

int updateCvGpuMatToBuf(int buff_fd, cv::cuda::GpuMat *src_gpu_mat)
{
    CUeglFrame egl_frame;
    CUgraphicsResource p_resource = nullptr;
    NvBufSurface *cv_cache_buf;

    NvBufSurfaceFromFd(buff_fd, (void **)&cv_cache_buf);

    cudaFree(0);
    NvBufSurfaceMapEglImage(cv_cache_buf, 0);

    auto egl_image = cv_cache_buf->surfaceList[0].mappedAddr.eglImage;
    cuGraphicsEGLRegisterImage(&p_resource, egl_image, CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE);
    cuGraphicsResourceGetMappedEglFrame(&egl_frame, p_resource, 0, 0);
    cuCtxSynchronize();

    cv::cuda::GpuMat d_mat(height, width, CV_8UC4, egl_frame.frame.pPitch[0]);
    src_gpu_mat->copyTo(d_mat);

    cudaDeviceSynchronize();
    cuCtxSynchronize();
    cuGraphicsUnregisterResource(p_resource);
    NvBufSurfaceUnMapEglImage(cv_cache_buf, 0);
    NvBufSurfaceSyncForDevice(cv_cache_buf, 0, 0);
    return 0;
}

What do you mean about the buff fd does not change?

the content of the src_gpu_mat image is not copied to cv_cache_buf

OK. Could you refer to the how-to-create-opencv-gpumat-from-nvstream? And could you give us a simple demo we can run to reproduce this issue?

ok, I will try, Thank you for your answer