code: def save_mtmct_crops(
      cid_tid_fid_res, images_dir, crops_dir, width=300, height=200
  ):
      camera_ids = cid_tid_fid_res.keys()
      seqs_folder = os.listdir(images_dir)
      seqs = []
      for x in seqs_folder:
          if os.path.isdir(os.path.join(images_dir, x)):
              seqs.append(x)
      assert len(seqs) == len(camera_ids)
      seqs.sort()
  
      if not os.path.exists(crops_dir):
          os.makedirs(crops_dir)
  
      common_tids = list(cid_tid_fid_res[list(camera_ids)[0]].keys())
  
      # get crops by name 'tid_cid_fid.jpg
      for t_id in common_tids:
          for i, c_id in enumerate(camera_ids):
              infer_dir = os.path.join(images_dir, seqs[i])
              if os.path.exists(os.path.join(infer_dir, "img1")):
                  infer_dir = os.path.join(infer_dir, "img1")
              all_images = os.listdir(infer_dir)
              all_images.sort()
  
              for f_id in cid_tid_fid_res[c_id][t_id].keys():
                  frame_idx = f_id - 1 if f_id > 0 else 0
                  im_path = os.path.join(
                      infer_dir, all_images[frame_idx]
                  )
  
                  im = cv2.imread(im_path)  # (H, W, 3)
  
                  # only select one track
                  track = cid_tid_fid_res[c_id][t_id][f_id][0]
  
                  cid, tid, fid, x1, y1, w, h = [int(v) for v in track]
                  clip = im[y1 : (y1 + h), x1 : (x1 + w)]
                  clip = cv2.resize(clip, (width, height))
  
                  cv2.imwrite(
                      os.path.join(
                          crops_dir,
                          "tid{:06d}_cid{:06d}_fid{:06d}.jpg".format(
                              tid, cid, fid
                          ),
                      ),
                      clip,
                  )
  
              print(
                  "Finish cropping image of tracked_id {} in camera: {}".format(
                      t_id, c_id
                  )
              )
  
file_path: PaddleDetection/deploy/pptracking/python/mot/mtmct/postprocess.py
imports: import os
  import re
  import cv2
  from tqdm import tqdm
  import numpy
  from functools import reduce
  from .utils import parse_pt_gt, parse_pt, compare_dataframes_mtmc
  from .utils import get_labels, getData, gen_new_mot
  from .camera_utils import get_labels_with_camera
  from .zone import Zone
  from ..visualize import plot_tracking
label_desc: Use image node_id 6 for calling a global function with example usage: save_mtmct_crops(cid_tid_fid_res, images_dir, crops_dir, width, height) without return types