alpha_comp

savant.deepstream.opencv_utils.alpha_comp(frame, overlay, start, alpha_op=cv2.cuda.ALPHA_OVER, stream=None)

In place composition of two images using alpha opacity values contained in each image.

Usage example:

overlay = cv2.imread("overlay.png", cv2.IMREAD_UNCHANGED)
with nvds_to_gpu_mat(gst_buffer, nvds_frame_meta) as frame_mat:
    # Place overlay on the frame
    alpha_comp(frame_mat, overlay, (300, 400))
Parameters:
  • frame (cv2.cuda.GpuMat) – Base image. Note: this image will be changed.

  • overlay (Union[cv2.cuda.GpuMat, ndarray]) – The image to overlay.

  • start (Tuple[int, int]) – Top-left corner of the overlay on the frame.

  • alpha_op – Flag specifying the alpha-blending operation.

  • stream (Optional[cv2.cuda.Stream]) – CUDA stream.