code: def make_label_2019(list_dir, save_gt_folder, phase):
      crop_img_save_dir = os.path.join(
          save_gt_folder, phase, "crop_imgs"
      )
      os.makedirs(crop_img_save_dir, exist_ok=True)
  
      f_det = open(
          os.path.join(save_gt_folder, phase, "det.txt"),
          "w",
          encoding="utf-8",
      )
      f_rec = open(
          os.path.join(save_gt_folder, phase, "rec.txt"),
          "w",
          encoding="utf-8",
      )
  
      with open(os.path.join(list_dir, phase + ".txt"), "r") as rf:
          imglist = rf.readlines()
  
      i = 0
      for idx, filename in enumerate(imglist):
          if idx % 1000 == 0:
              print("{}/{}".format(idx, len(imglist)))
          filename = filename.strip()
          str_list = filename.split("-")
          if len(str_list) < 5:
              continue
          coord_list = str_list[3].split("_")
          txt_list = str_list[4].split("_")
          boxes = []
          for coord in coord_list:
              boxes.append([int(x) for x in coord.split("&")])
          boxes = [boxes[2], boxes[3], boxes[0], boxes[1]]
          lp_number = (
              provinces[int(txt_list[0])]
              + alphabets[int(txt_list[1])]
              + "".join([ads[int(x)] for x in txt_list[2:]])
          )
  
          # det
          det_info = [{"points": boxes, "transcription": lp_number}]
          f_det.write(
              "{}\t{}\n".format(
                  os.path.join("CCPD2019", filename),
                  json.dumps(det_info, ensure_ascii=False),
              )
          )
  
          # rec
          boxes = np.float32(boxes)
          imgpath = os.path.join(list_dir[:-7], filename)
          img = cv2.imread(imgpath)
          # crop_img = img[int(boxes[:,1].min()):int(boxes[:,1].max()),int(boxes[:,0].min()):int(boxes[:,0].max())]
          crop_img = get_rotate_crop_image(img, boxes)
          crop_img_save_filename = "{}_{}.jpg".format(
              i, "_".join(txt_list)
          )
          crop_img_save_path = os.path.join(
              crop_img_save_dir, crop_img_save_filename
          )
          cv2.imwrite(crop_img_save_path, crop_img)
          f_rec.write(
              "{}/{}/crop_imgs/{}\t{}\n".format(
                  "CCPD2019/PPOCR",
                  phase,
                  crop_img_save_filename,
                  lp_number,
              )
          )
          i += 1
      f_det.close()
      f_rec.close()
  
file_path: PaddleDetection/deploy/pipeline/tools/ccpd2ocr_all.py
imports: import cv2
  import os
  import json
  from tqdm import tqdm
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: make_label_2019(list_dir, save_gt_folder, phase) without return types