class_docstr: Visualizer that draws data about detection on images.
  
  It contains methods like `draw_{text,box}`
  that draw primitive objects to images, as well as high-level wrappers like
  `draw_{instance_predictions}` that draw composite data in some pre-defined style.
  
  Note that the exact visualization style for the high-level wrappers are subject to change.
  Style such as color, opacity, label contents, visibility of labels, or even the visibility
  of objects themselves (e.g. when the object is too small) may change according
  to different heuristics, as long as the results still look visually reasonable.
  
  To obtain a consistent style, you can implement custom drawing functions with the
  abovementioned primitive methods instead.  This class does not intend to satisfy
  everyone's preference on drawing styles.
  
  This visualizer focuses on high rendering quality rather than performance. It is not
  designed to be used for real-time applications.
class_docstr_tok: ["Visualizer","that","draws","data","about","detection","on","images",".","It","contains","methods","like","`","draw_","{","text",",","box","}","`","that","draw","primitive","objects","to","images",",","as","well","as","high-level","wrappers","like","`","draw_","{","instance_predictions","}","`","that","draw","composite","data","in","some","pre-defined","style",".","Note","that","the","exact","visualization","style","for","the","high-level","wrappers","are","subject","to","change",".","Style","such","as","color",",","opacity",",","label","contents",",","visibility","of","labels",",","or","even","the","visibility","of","objects","themselves","(","e.g",".","when","the","object","is","too","small",")","may","change","according","to","different","heuristics",",","as","long","as","the","results","still","look","visually","reasonable",".","To","obtain","a","consistent","style",",","you","can","implement","custom","drawing","functions","with","the","abovementioned","primitive","methods","instead",".","This","class","does","not","intend","to","satisfy","everyone","'s","preference","on","drawing","styles",".","This","visualizer","focuses","on","high","rendering","quality","rather","than","performance",".","It","is","not","designed","to","be","used","for","real-time","applications","."]
docstr: Parameters
  ----------
  img_rgb: a numpy array of shape (H, W, C), where H and W correspond to
      the height and width of the image respectively. C is the number of
      color channels. The image is required to be in RGB format since that
      is a requirement of the Matplotlib library. The image is also expected
      to be in the range [0, 255].
  metadata (Metadata): dataset metadata (e.g. class names and colors)
  instance_mode (ColorMode): defines one of the pre-defined style for drawing
      instances on an image.
code: def __init__(
      self, img_path, scale=1.0, instance_mode=ColorMode.IMAGE
  ):
      """
      Parameters
      ----------
      img_rgb: a numpy array of shape (H, W, C), where H and W correspond to
          the height and width of the image respectively. C is the number of
          color channels. The image is required to be in RGB format since that
          is a requirement of the Matplotlib library. The image is also expected
          to be in the range [0, 255].
      metadata (Metadata): dataset metadata (e.g. class names and colors)
      instance_mode (ColorMode): defines one of the pre-defined style for drawing
          instances on an image.
      """
      try:
          import cv2
      except:
          raise ImportError(
              "No module named: cv2. Please install cv2 by 'pip install opencv-python'"
          )
  
      img_rgb = cv2.imread(img_path)
      img_rgb = img_rgb[:, :, ::-1]
      self.img = np.asarray(img_rgb).clip(0, 255).astype(np.uint8)
      self.output = VisImage(self.img, scale=scale)
  
      # too small texts are useless, therefore clamp to 9
      self._default_font_size = max(
          np.sqrt(self.output.height * self.output.width) // 90,
          10 // scale,
      )
      self._instance_mode = instance_mode
  
imports: import collections
  import colorsys
  import logging
  import re
  from enum import Enum, unique
  from typing import List
  import matplotlib
  import matplotlib.colors
  import matplotlib.figure
  import matplotlib.pyplot
  import numpy
  import pandas
  from matplotlib.backends.backend_agg import FigureCanvasAgg
  from PIL import Image
  from .colormap import random_color
  from .misc import merge_spans
label_desc: Use image node_id 1 to create a new ObjectDetectionVisualizer object  with example: obj = ObjectDetectionVisualizer(img_path, scale, instance_mode)