code: def draw_detection(
      image: np.ndarray,
      detection: detection_pb2.Detection,
      keypoint_drawing_spec: DrawingSpec = DrawingSpec(color=RED_COLOR),
      bbox_drawing_spec: DrawingSpec = DrawingSpec(),
  ):
      """Draws the detction bounding box and keypoints on the image.
  
      Args:
        image: A three channel BGR image represented as numpy ndarray.
        detection: A detection proto message to be annotated on the image.
        keypoint_drawing_spec: A DrawingSpec object that specifies the keypoints'
          drawing settings such as color, line thickness, and circle radius.
        bbox_drawing_spec: A DrawingSpec object that specifies the bounding box's
          drawing settings such as color and line thickness.
  
      Raises:
        ValueError: If one of the followings:
          a) If the input image is not three channel BGR.
          b) If the location data is not relative data.
      """
      if not detection.location_data:
          return
      if image.shape[2] != _BGR_CHANNELS:
          raise ValueError(
              "Input image must contain three channel bgr data."
          )
      image_rows, image_cols, _ = image.shape
  
      location = detection.location_data
      if (
          location.format
          != location_data_pb2.LocationData.RELATIVE_BOUNDING_BOX
      ):
          raise ValueError(
              "LocationData must be relative for this drawing funtion to work."
          )
      # Draws keypoints.
      for keypoint in location.relative_keypoints:
          keypoint_px = _normalized_to_pixel_coordinates(
              keypoint.x, keypoint.y, image_cols, image_rows
          )
          cv2.circle(
              image,
              keypoint_px,
              keypoint_drawing_spec.circle_radius,
              keypoint_drawing_spec.color,
              keypoint_drawing_spec.thickness,
          )
      # Draws bounding box if exists.
      if not location.HasField("relative_bounding_box"):
          return
      relative_bounding_box = location.relative_bounding_box
      rect_start_point = _normalized_to_pixel_coordinates(
          relative_bounding_box.xmin,
          relative_bounding_box.ymin,
          image_cols,
          image_rows,
      )
      rect_end_point = _normalized_to_pixel_coordinates(
          relative_bounding_box.xmin + relative_bounding_box.width,
          relative_bounding_box.ymin + relative_bounding_box.height,
          image_cols,
          image_rows,
      )
      cv2.rectangle(
          image,
          rect_start_point,
          rect_end_point,
          bbox_drawing_spec.color,
          bbox_drawing_spec.thickness,
      )
  
file_path: mediapipe/mediapipe/python/solutions/drawing_utils.py
imports: import dataclasses
  import math
  from typing import List, Mapping, Optional, Tuple, Union
  import cv2
  import matplotlib.pyplot
  import numpy
  from mediapipe.framework.formats import detection_pb2
  from mediapipe.framework.formats import landmark_pb2
  from mediapipe.framework.formats import location_data_pb2
label_desc: Use image node_id 2 for calling a global function with example usage: draw_detection(image, detection, keypoint_drawing_spec, bbox_drawing_spec) without return types