code: def draw_pose(
      image,
      results,
      visual_thread=0.6,
      save_name="pose.jpg",
      save_dir="output",
      returnimg=False,
      ids=None,
  ):
      try:
          import matplotlib.pyplot as plt
          import matplotlib
  
          plt.switch_backend("agg")
      except Exception as e:
          logger.error(
              "Matplotlib not found, please install matplotlib."
              "for example: `pip install matplotlib`."
          )
          raise e
  
      skeletons = np.array([item["keypoints"] for item in results])
      kpt_nums = 17
      if len(skeletons) > 0:
          kpt_nums = int(skeletons.shape[1] / 3)
      skeletons = skeletons.reshape(-1, kpt_nums, 3)
      if kpt_nums == 17:  # plot coco keypoint
          EDGES = [
              (0, 1),
              (0, 2),
              (1, 3),
              (2, 4),
              (3, 5),
              (4, 6),
              (5, 7),
              (6, 8),
              (7, 9),
              (8, 10),
              (5, 11),
              (6, 12),
              (11, 13),
              (12, 14),
              (13, 15),
              (14, 16),
              (11, 12),
          ]
      else:  # plot mpii keypoint
          EDGES = [
              (0, 1),
              (1, 2),
              (3, 4),
              (4, 5),
              (2, 6),
              (3, 6),
              (6, 7),
              (7, 8),
              (8, 9),
              (10, 11),
              (11, 12),
              (13, 14),
              (14, 15),
              (8, 12),
              (8, 13),
          ]
      NUM_EDGES = len(EDGES)
  
      colors = [
          [255, 0, 0],
          [255, 85, 0],
          [255, 170, 0],
          [255, 255, 0],
          [170, 255, 0],
          [85, 255, 0],
          [0, 255, 0],
          [0, 255, 85],
          [0, 255, 170],
          [0, 255, 255],
          [0, 170, 255],
          [0, 85, 255],
          [0, 0, 255],
          [85, 0, 255],
          [170, 0, 255],
          [255, 0, 255],
          [255, 0, 170],
          [255, 0, 85],
      ]
      cmap = matplotlib.cm.get_cmap("hsv")
      plt.figure()
  
      img = np.array(image).astype("float32")
  
      color_set = results["colors"] if "colors" in results else None
  
      if "bbox" in results and ids is None:
          bboxs = results["bbox"]
          for j, rect in enumerate(bboxs):
              xmin, ymin, xmax, ymax = rect
              color = (
                  colors[0]
                  if color_set is None
                  else colors[color_set[j] % len(colors)]
              )
              cv2.rectangle(img, (xmin, ymin), (xmax, ymax), color, 1)
  
      canvas = img.copy()
      for i in range(kpt_nums):
          for j in range(len(skeletons)):
              if skeletons[j][i, 2] < visual_thread:
                  continue
              if ids is None:
                  color = (
                      colors[i]
                      if color_set is None
                      else colors[color_set[j] % len(colors)]
                  )
              else:
                  color = get_color(ids[j])
  
              cv2.circle(
                  canvas,
                  tuple(skeletons[j][i, 0:2].astype("int32")),
                  2,
                  color,
                  thickness=-1,
              )
  
      to_plot = cv2.addWeighted(img, 0.3, canvas, 0.7, 0)
      fig = matplotlib.pyplot.gcf()
  
      stickwidth = 2
  
      for i in range(NUM_EDGES):
          for j in range(len(skeletons)):
              edge = EDGES[i]
              if (
                  skeletons[j][edge[0], 2] < visual_thread
                  or skeletons[j][edge[1], 2] < visual_thread
              ):
                  continue
  
              cur_canvas = canvas.copy()
              X = [skeletons[j][edge[0], 1], skeletons[j][edge[1], 1]]
              Y = [skeletons[j][edge[0], 0], skeletons[j][edge[1], 0]]
              mX = np.mean(X)
              mY = np.mean(Y)
              length = ((X[0] - X[1]) ** 2 + (Y[0] - Y[1]) ** 2) ** 0.5
              angle = math.degrees(math.atan2(X[0] - X[1], Y[0] - Y[1]))
              polygon = cv2.ellipse2Poly(
                  (int(mY), int(mX)),
                  (int(length / 2), stickwidth),
                  int(angle),
                  0,
                  360,
                  1,
              )
              if ids is None:
                  color = (
                      colors[i]
                      if color_set is None
                      else colors[color_set[j] % len(colors)]
                  )
              else:
                  color = get_color(ids[j])
              cv2.fillConvexPoly(cur_canvas, polygon, color)
              canvas = cv2.addWeighted(canvas, 0.4, cur_canvas, 0.6, 0)
      image = Image.fromarray(canvas.astype("uint8"))
      plt.close()
      return image
  
file_path: PaddleDetection/ppdet/utils/visualizer.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import os
  import numpy
  from PIL import Image, ImageDraw, ImageFont
  import cv2
  import math
  from .colormap import colormap
  from ppdet.utils.logger import setup_logger
  from ppdet.utils.compact import imagedraw_textsize_c
  from ppdet.utils.download import get_path
label_desc: Use image node_id 6 for calling a global function with example usage: draw_pose(image, results, visual_thread, save_name, save_dir, returnimg, ids) and returns: image