code: def crop_image_by_bbox(self, image, box, word):
      w = max(
          int(np.linalg.norm(box[0] - box[1])),
          int(np.linalg.norm(box[2] - box[3])),
      )
      h = max(
          int(np.linalg.norm(box[0] - box[3])),
          int(np.linalg.norm(box[1] - box[2])),
      )
      try:
          word_ratio = h / w
      except:
          import ipdb
  
          ipdb.set_trace()
  
      one_char_ratio = min(h, w) / (max(h, w) / len(word))
  
      # NOTE: criterion to split vertical word in here is set to work properly on IC15 dataset
      if word_ratio > 2 or (word_ratio > 1.6 and one_char_ratio > 2.4):
          # warping method of vertical word (classified by upper condition)
          horizontal_text_bool = False
          long_side = h
          short_side = w
          M = cv2.getPerspectiveTransform(
              np.float32(box),
              np.float32(
                  np.array(
                      [
                          [long_side, 0],
                          [long_side, short_side],
                          [0, short_side],
                          [0, 0],
                      ]
                  )
              ),
          )
          self.flag = True
      else:
          # warping method of horizontal word
          horizontal_text_bool = True
          long_side = w
          short_side = h
          M = cv2.getPerspectiveTransform(
              np.float32(box),
              np.float32(
                  np.array(
                      [
                          [0, 0],
                          [long_side, 0],
                          [long_side, short_side],
                          [0, short_side],
                      ]
                  )
              ),
          )
          self.flag = False
  
      warped = cv2.warpPerspective(image, M, (long_side, short_side))
      return warped, M, horizontal_text_bool
  
file_path: EasyOCR/trainer/craft/data/pseudo_label/make_charbox.py
imports: import os
  import random
  import math
  import numpy
  import cv2
  import torch
  from data import imgproc
  from data.pseudo_label.watershed import exec_watershed_by_version
label_desc: Use image node_id 2 for calling the PseudoCharBoxBuilder obj's underlying member method code with example usage: obj.crop_image_by_bbox(image, box, word) and returns: warped,  M,  horizontal_text_bool