How to capture image which can directly using by CUDA?

Hi,
An optimal solution is to run gstreamer command and get the buffer in appsink like:

rtspsrc ! rtph265depay ! h265parse ! nvv4l2decoder ! appsink

And use NvBufSurface APIs to map the buffer to cv::gpuMat. Here is a sample for Jetpack 4
Nano not using GPU with gstreamer/python. Slow FPS, dropped frames - #8 by DaneLLL

The sample cannot be applied directly since we have deprecated NvBuffer APIs on Jetpack 5. Please also refer to this patch which uses NVBufSurface APIs:
How to create opencv gpumat from nvstream? - #18 by DaneLLL