code: def gen_res(
      output_dir_filename,
      scene_cluster,
      map_tid,
      mot_list_breaks,
      use_roi=False,
      roi_dir="",
  ):
      f_w = open(output_dir_filename, "w")
      for idx, mot_feature in enumerate(mot_list_breaks):
          cid = scene_cluster[idx]
          img_rects = parse_pt_gt(mot_feature)
          if use_roi:
              assert roi_dir != "", "Error: roi_dir is not empty!"
              roi = cv2.imread(
                  os.path.join(roi_dir, f"c{cid:03d}/roi.jpg"), 0
              )
              height, width = roi.shape
  
          for fid in img_rects:
              tid_rects = img_rects[fid]
              fid = int(fid) + 1
              for tid_rect in tid_rects:
                  tid = tid_rect[0]
                  rect = tid_rect[1:]
                  cx = 0.5 * rect[0] + 0.5 * rect[2]
                  cy = 0.5 * rect[1] + 0.5 * rect[3]
                  w = rect[2] - rect[0]
                  w = min(w * 1.2, w + 40)
                  h = rect[3] - rect[1]
                  h = min(h * 1.2, h + 40)
                  rect[2] -= rect[0]
                  rect[3] -= rect[1]
                  rect[0] = max(0, rect[0])
                  rect[1] = max(0, rect[1])
                  x1, y1 = max(0, cx - 0.5 * w), max(0, cy - 0.5 * h)
                  if use_roi:
                      x2, y2 = min(width, cx + 0.5 * w), min(
                          height, cy + 0.5 * h
                      )
                  else:
                      x2, y2 = cx + 0.5 * w, cy + 0.5 * h
                  w, h = x2 - x1, y2 - y1
                  new_rect = list(map(int, [x1, y1, w, h]))
                  rect = list(map(int, rect))
                  if (cid, tid) in map_tid:
                      new_tid = map_tid[(cid, tid)]
                      f_w.write(
                          str(cid)
                          + " "
                          + str(new_tid)
                          + " "
                          + str(fid)
                          + " "
                          + " ".join(map(str, new_rect))
                          + " -1 -1"
                          "\n"
                      )
      print("gen_res: write file in {}".format(output_dir_filename))
      f_w.close()
  
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 3 for calling a global function with example usage: gen_res(output_dir_filename, scene_cluster, map_tid, mot_list_breaks, use_roi, roi_dir) without return types