code: def process_level(
      src_img,
      annotation,
      dst_image_root,
      ignore_image_root,
      preserve_vertical,
      split,
      para_idx,
      img_idx,
      line_idx,
      word_idx=None,
  ):
      vertices = annotation["vertices"]
      text_label = annotation["text"]
      segmentation = [i for j in vertices for i in j]
      x, y, w, h = seg2bbox(segmentation)
      x, y = max(0, math.floor(x)), max(0, math.floor(y))
      w, h = math.ceil(w), math.ceil(h)
      dst_img = src_img[y : y + h, x : x + w]
      if word_idx:
          dst_img_name = (
              f"img_{img_idx}_{para_idx}_{line_idx}_{word_idx}.jpg"
          )
      else:
          dst_img_name = f"img_{img_idx}_{para_idx}_{line_idx}.jpg"
      if not preserve_vertical and h / w > 2 and split == "train":
          dst_img_path = osp.join(ignore_image_root, dst_img_name)
          mmcv.imwrite(dst_img, dst_img_path)
          return None
  
      dst_img_path = osp.join(dst_image_root, dst_img_name)
      mmcv.imwrite(dst_img, dst_img_path)
  
      label = {
          "file_name": dst_img_name,
          "anno_info": [{"text": text_label}],
      }
  
      return label
  
file_path: mmocr/tools/dataset_converters/textrecog/hiertext_converter.py
imports: import argparse
  import json
  import math
  import os.path
  from functools import partial
  import mmcv
  import mmengine
  import numpy
  from shapely.geometry import Polygon
  from mmocr.utils import dump_ocr_data
label_desc: Use image node_id 2 for calling a global function with example usage: process_level(src_img, annotation, dst_image_root, ignore_image_root, preserve_vertical, split, para_idx, img_idx, line_idx, word_idx) and returns: label, None