code: def _cv2_show_wrong_tracks(
      img: Union[str, np.ndarray],
      bboxes: np.ndarray,
      ids: np.ndarray,
      error_types: np.ndarray,
      thickness: int = 2,
      font_scale: float = 0.4,
      text_width: int = 10,
      text_height: int = 15,
      show: bool = False,
      wait_time: int = 100,
      out_file: str = None,
  ) -> np.ndarray:
      """Show the wrong tracks with opencv.
  
      Args:
          img (str or ndarray): The image to be displayed.
          bboxes (ndarray): A ndarray of shape (k, 5).
          ids (ndarray): A ndarray of shape (k, ).
          error_types (ndarray): A ndarray of shape (k, ), where 0 denotes
              false positives, 1 denotes false negative and 2 denotes ID switch.
          thickness (int, optional): Thickness of lines.
              Defaults to 2.
          font_scale (float, optional): Font scale to draw id and score.
              Defaults to 0.4.
          text_width (int, optional): Width to draw id and score.
              Defaults to 10.
          text_height (int, optional): Height to draw id and score.
              Defaults to 15.
          show (bool, optional): Whether to show the image on the fly.
              Defaults to False.
          wait_time (int, optional): Value of waitKey param.
              Defaults to 100.
          out_file (str, optional): The filename to write the image.
              Defaults to None.
  
      Returns:
          ndarray: Visualized image.
      """
      if sns is None:
          raise ImportError("please run pip install seaborn")
      assert (
          bboxes.ndim == 2
      ), f" bboxes ndim should be 2, but its ndim is {bboxes.ndim}."
      assert (
          ids.ndim == 1
      ), f" ids ndim should be 1, but its ndim is {ids.ndim}."
      assert (
          error_types.ndim == 1
      ), f" error_types ndim should be 1, but its ndim is {error_types.ndim}."
      assert (
          bboxes.shape[0] == ids.shape[0]
      ), "bboxes.shape[0] and ids.shape[0] should have the same length."
      assert (
          bboxes.shape[1] == 5
      ), f" bboxes.shape[1] should be 5, but its {bboxes.shape[1]}."
  
      bbox_colors = sns.color_palette()
      # red, yellow, blue
      bbox_colors = [bbox_colors[3], bbox_colors[1], bbox_colors[0]]
      bbox_colors = [
          [int(255 * _c) for _c in bbox_color][::-1]
          for bbox_color in bbox_colors
      ]
  
      if isinstance(img, str):
          img = mmcv.imread(img)
      else:
          assert img.ndim == 3
  
      img_shape = img.shape
      bboxes[:, 0::2] = np.clip(bboxes[:, 0::2], 0, img_shape[1])
      bboxes[:, 1::2] = np.clip(bboxes[:, 1::2], 0, img_shape[0])
  
      for bbox, error_type, id in zip(bboxes, error_types, ids):
          x1, y1, x2, y2 = bbox[:4].astype(np.int32)
          score = float(bbox[-1])
  
          # bbox
          bbox_color = bbox_colors[error_type]
          cv2.rectangle(
              img, (x1, y1), (x2, y2), bbox_color, thickness=thickness
          )
  
          # FN does not have id and score
          if error_type == 1:
              continue
  
          # score
          text = "{:.02f}".format(score)
          width = (len(text) - 1) * text_width
          img[y1 : y1 + text_height, x1 : x1 + width, :] = bbox_color
          cv2.putText(
              img,
              text,
              (x1, y1 + text_height - 2),
              cv2.FONT_HERSHEY_COMPLEX,
              font_scale,
              color=(0, 0, 0),
          )
  
          # id
          text = str(id)
          width = len(text) * text_width
          img[
              y1 + text_height : y1 + text_height * 2,
              x1 : x1 + width,
              :,
          ] = bbox_color
          cv2.putText(
              img,
              str(id),
              (x1, y1 + text_height * 2 - 2),
              cv2.FONT_HERSHEY_COMPLEX,
              font_scale,
              color=(0, 0, 0),
          )
  
      if show:
          mmcv.imshow(img, wait_time=wait_time)
      if out_file is not None:
          mmcv.imwrite(img, out_file)
  
      return img
  
file_path: mmdetection/mmdet/utils/mot_error_visualize.py
imports: import os.path
  from typing import Union
  import cv2
  import matplotlib.pyplot
  import mmcv
  import numpy
  from matplotlib.patches import Rectangle
  from mmengine.utils import mkdir_or_exist
label_desc: Use image node_id 2 for calling a global function with example usage: _cv2_show_wrong_tracks(img, bboxes, ids, error_types, thickness, font_scale, text_width, text_height, show, wait_time, out_file) and returns: img