code: def get_textbox(
      detector,
      image,
      canvas_size,
      mag_ratio,
      text_threshold,
      link_threshold,
      low_text,
      poly,
      device,
      optimal_num_chars=None,
      **kwargs,
  ):
      result = []
      estimate_num_chars = optimal_num_chars is not None
      bboxes_list, polys_list = test_net(
          canvas_size,
          mag_ratio,
          detector,
          image,
          text_threshold,
          link_threshold,
          low_text,
          poly,
          device,
          estimate_num_chars,
      )
      if estimate_num_chars:
          polys_list = [
              [
                  p
                  for p, _ in sorted(
                      polys, key=lambda x: abs(optimal_num_chars - x[1])
                  )
              ]
              for polys in polys_list
          ]
  
      for polys in polys_list:
          single_img_result = []
          for i, box in enumerate(polys):
              poly = np.array(box).astype(np.int32).reshape((-1))
              single_img_result.append(poly)
          result.append(single_img_result)
  
      return result
  
file_path: EasyOCR/easyocr/detection.py
imports: import torch
  import torch.backends.cudnn
  from torch.autograd import Variable
  from PIL import Image
  from collections import OrderedDict
  import cv2
  import numpy
  from .craft_utils import getDetBoxes, adjustResultCoordinates
  from .imgproc import resize_aspect_ratio, normalizeMeanVariance
  from .craft import CRAFT
label_desc: Use image node_id 4 for calling a global function with example usage: get_textbox(detector, image, canvas_size, mag_ratio, text_threshold, link_threshold, low_text, poly, device, optimal_num_chars) and returns: result