nvds_to_gpu_mat

savant.deepstream.opencv_utils.nvds_to_gpu_mat(buffer, nvds_frame_meta=None, batch_id=None)

Build GpuMat header for allocated CUDA-memory of the frame.

Usage example:

with nvds_to_gpu_mat(buffer, nvds_frame_meta) as frame_mat:
    roi = cv2.cuda.GpuMat(frame_mat, (300, 400, 100, 200))
    # Fill area on the frame with red color
    roi.setTo((255, 0, 0, 255))
Parameters:
  • buffer (Buffer) – Gstreamer buffer which contains NvBufSurface.

  • nvds_frame_meta (pyds.NvDsFrameMeta) – NvDs frame metadata which contains frame info.

  • batch_id (int) – Frame ID in a batch. Ignored when nvds_frame_meta is specified.

Returns:

GpuMat header for allocated CUDA-memory of the frame.

Return type:

ContextManager[cv2.cuda.GpuMat]