code: def process_img(
      args,
      src_image_root,
      dst_image_root,
      ignore_image_root,
      preserve_vertical,
      split,
  ):
      # Dirty hack for multi-processing
      img_idx, img_info, anns = args
      src_img = mmcv.imread(
          osp.join(src_image_root, img_info["file_name"])
      )
      label = []
      for ann_idx, ann in enumerate(anns):
          text_label = ann["utf8_string"]
  
          # Ignore illegible or non-English words
          if ann["language"] == "not english":
              continue
          if ann["legibility"] == "illegible":
              continue
  
          x, y, w, h = ann["bbox"]
          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]
          dst_img_name = f"img_{img_idx}_{ann_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)
              continue
  
          dst_img_path = osp.join(dst_image_root, dst_img_name)
          mmcv.imwrite(dst_img, dst_img_path)
  
          label.append(
              {
                  "file_name": dst_img_name,
                  "anno_info": [{"text": text_label}],
              }
          )
  
      return label
  
file_path: mmocr/tools/dataset_converters/textrecog/cocotext_converter.py
imports: import argparse
  import math
  import os.path
  from functools import partial
  import mmcv
  import mmengine
  from mmocr.utils import dump_ocr_data
label_desc: Use image node_id 2 for calling a global function with example usage: process_img(args, src_image_root, dst_image_root, ignore_image_root, preserve_vertical, split) and returns: label