class_docstr: Args:
      model_dir (str): root path of model.pdiparams, model.pdmodel and infer_cfg.yml
      tracker_config (str): tracker config path
      device (str): Choose the device you want to run, it can be: CPU/GPU/XPU/NPU, default is CPU
      run_mode (str): mode of running(paddle/trt_fp32/trt_fp16)
      batch_size (int): size of pre batch in inference
      trt_min_shape (int): min shape for dynamic shape in trt
      trt_max_shape (int): max shape for dynamic shape in trt
      trt_opt_shape (int): opt shape for dynamic shape in trt
      trt_calib_mode (bool): If the model is produced by TRT offline quantitative
          calibration, trt_calib_mode need to set True
      cpu_threads (int): cpu threads
      enable_mkldnn (bool): whether to open MKLDNN
      output_dir (string): The path of output, default as 'output'
      threshold (float): Score threshold of the detected bbox, default as 0.5
      save_images (bool): Whether to save visualization image results, default as False
      save_mot_txts (bool): Whether to save tracking results (txt), default as False
      draw_center_traj (bool): Whether drawing the trajectory of center, default as False
      secs_interval (int): The seconds interval to count after tracking, default as 10
      skip_frame_num (int): Skip frame num to get faster MOT results, default as -1
      warmup_frame (int):Warmup frame num to test speed of MOT,default as 50
      do_entrance_counting(bool): Whether counting the numbers of identifiers entering 
          or getting out from the entrance, default as False，only support single class
          counting in MOT, and the video should be taken by a static camera.
      do_break_in_counting(bool): Whether counting the numbers of identifiers break in
          the area, default as False，only support single class counting in MOT,
          and the video should be taken by a static camera.
      region_type (str): Area type for entrance counting or break in counting, 'horizontal'
          and 'vertical' used when do entrance counting. 'custom' used when do break in counting. 
          Note that only support single-class MOT, and the video should be taken by a static camera.
      region_polygon (list): Clockwise point coords (x0,y0,x1,y1...) of polygon of area when
          do_break_in_counting. Note that only support single-class MOT and
          the video should be taken by a static camera.
      reid_model_dir (str): reid model dir, default None for ByteTrack, but set for DeepSORT
      mtmct_dir (str): MTMCT dir, default None, set for doing MTMCT
class_docstr_tok: ["Args",":","model_dir","(","str",")",":","root","path","of","model.pdiparams",",","model.pdmodel","and","infer_cfg.yml","tracker_config","(","str",")",":","tracker","config","path","device","(","str",")",":","Choose","the","device","you","want","to","run",",","it","can","be",":","CPU\/GPU\/XPU\/NPU",",","default","is","CPU","run_mode","(","str",")",":","mode","of","running","(","paddle\/trt_fp32\/trt_fp16",")","batch_size","(","int",")",":","size","of","pre","batch","in","inference","trt_min_shape","(","int",")",":","min","shape","for","dynamic","shape","in","trt","trt_max_shape","(","int",")",":","max","shape","for","dynamic","shape","in","trt","trt_opt_shape","(","int",")",":","opt","shape","for","dynamic","shape","in","trt","trt_calib_mode","(","bool",")",":","If","the","model","is","produced","by","TRT","offline","quantitative","calibration",",","trt_calib_mode","need","to","set","True","cpu_threads","(","int",")",":","cpu","threads","enable_mkldnn","(","bool",")",":","whether","to","open","MKLDNN","output_dir","(","string",")",":","The","path","of","output",",","default","as","'output'","threshold","(","float",")",":","Score","threshold","of","the","detected","bbox",",","default","as","0.5","save_images","(","bool",")",":","Whether","to","save","visualization","image","results",",","default","as","False","save_mot_txts","(","bool",")",":","Whether","to","save","tracking","results","(","txt",")",",","default","as","False","draw_center_traj","(","bool",")",":","Whether","drawing","the","trajectory","of","center",",","default","as","False","secs_interval","(","int",")",":","The","seconds","interval","to","count","after","tracking",",","default","as","10","skip_frame_num","(","int",")",":","Skip","frame","num","to","get","faster","MOT","results",",","default","as","-1","warmup_frame","(","int",")",":","Warmup","frame","num","to","test","speed","of","MOT",",","default","as","50","do_entrance_counting","(","bool",")",":","Whether","counting","the","numbers","of","identifiers","entering","or","getting","out","from","the","entrance",",","default","as","False\uff0conly","support","single","class","counting","in","MOT",",","and","the","video","should","be","taken","by","a","static","camera",".","do_break_in_counting","(","bool",")",":","Whether","counting","the","numbers","of","identifiers","break","in","the","area",",","default","as","False\uff0conly","support","single","class","counting","in","MOT",",","and","the","video","should","be","taken","by","a","static","camera",".","region_type","(","str",")",":","Area","type","for","entrance","counting","or","break","in","counting",",","'horizontal'","and","'vertical","'","used","when","do","entrance","counting",".","'custom","'","used","when","do","break","in","counting",".","Note","that","only","support","single-class","MOT",",","and","the","video","should","be","taken","by","a","static","camera",".","region_polygon","(","list",")",":","Clockwise","point","coords","(","x0",",","y0",",","x1",",","y1","...",")","of","polygon","of","area","when","do_break_in_counting",".","Note","that","only","support","single-class","MOT","and","the","video","should","be","taken","by","a","static","camera",".","reid_model_dir","(","str",")",":","reid","model","dir",",","default","None","for","ByteTrack",",","but","set","for","DeepSORT","mtmct_dir","(","str",")",":","MTMCT","dir",",","default","None",",","set","for","doing","MTMCT"]
code: def __init__(
      self,
      model_dir,
      tracker_config,
      device="CPU",
      run_mode="paddle",
      batch_size=1,
      trt_min_shape=1,
      trt_max_shape=1280,
      trt_opt_shape=640,
      trt_calib_mode=False,
      cpu_threads=1,
      enable_mkldnn=False,
      output_dir="output",
      threshold=0.5,
      save_images=False,
      save_mot_txts=False,
      draw_center_traj=False,
      secs_interval=10,
      skip_frame_num=-1,
      warmup_frame=50,
      do_entrance_counting=False,
      do_break_in_counting=False,
      region_type="horizontal",
      region_polygon=[],
      reid_model_dir=None,
      mtmct_dir=None,
  ):
      super(SDE_Detector, self).__init__(
          model_dir=model_dir,
          device=device,
          run_mode=run_mode,
          batch_size=batch_size,
          trt_min_shape=trt_min_shape,
          trt_max_shape=trt_max_shape,
          trt_opt_shape=trt_opt_shape,
          trt_calib_mode=trt_calib_mode,
          cpu_threads=cpu_threads,
          enable_mkldnn=enable_mkldnn,
          output_dir=output_dir,
          threshold=threshold,
      )
      self.save_images = save_images
      self.save_mot_txts = save_mot_txts
      self.draw_center_traj = draw_center_traj
      self.secs_interval = secs_interval
      self.skip_frame_num = skip_frame_num
      self.warmup_frame = warmup_frame
      self.do_entrance_counting = do_entrance_counting
      self.do_break_in_counting = do_break_in_counting
      self.region_type = region_type
      self.region_polygon = region_polygon
      if self.region_type == "custom":
          assert (
              len(self.region_polygon) > 6
          ), "region_type is custom, region_polygon should be at least 3 pairs of point coords."
  
      assert batch_size == 1, "MOT model only supports batch_size=1."
      self.det_times = Timer(with_tracker=True)
      self.num_classes = len(self.pred_config.labels)
      if self.skip_frame_num > 1:
          self.previous_det_result = None
  
      # reid config
      self.use_reid = False if reid_model_dir is None else True
      if self.use_reid:
          self.reid_pred_config = self.set_config(reid_model_dir)
          self.reid_predictor, self.config = load_predictor(
              reid_model_dir,
              run_mode=run_mode,
              batch_size=50,  # reid_batch_size
              min_subgraph_size=self.reid_pred_config.min_subgraph_size,
              device=device,
              use_dynamic_shape=self.reid_pred_config.use_dynamic_shape,
              trt_min_shape=trt_min_shape,
              trt_max_shape=trt_max_shape,
              trt_opt_shape=trt_opt_shape,
              trt_calib_mode=trt_calib_mode,
              cpu_threads=cpu_threads,
              enable_mkldnn=enable_mkldnn,
          )
      else:
          self.reid_pred_config = None
          self.reid_predictor = None
  
      assert (
          tracker_config is not None
      ), "Note that tracker_config should be set."
      self.tracker_config = tracker_config
      tracker_cfg = yaml.safe_load(open(self.tracker_config))
      cfg = tracker_cfg[tracker_cfg["type"]]
  
      # tracker config
      self.use_deepsort_tracker = (
          True if tracker_cfg["type"] == "DeepSORTTracker" else False
      )
      self.use_ocsort_tracker = (
          True if tracker_cfg["type"] == "OCSORTTracker" else False
      )
      self.use_botsort_tracker = (
          True if tracker_cfg["type"] == "BOTSORTTracker" else False
      )
  
      if self.use_deepsort_tracker:
          if self.reid_pred_config is not None and hasattr(
              self.reid_pred_config, "tracker"
          ):
              cfg = self.reid_pred_config.tracker
          budget = cfg.get("budget", 100)
          max_age = cfg.get("max_age", 30)
          max_iou_distance = cfg.get("max_iou_distance", 0.7)
          matching_threshold = cfg.get("matching_threshold", 0.2)
          min_box_area = cfg.get("min_box_area", 0)
          vertical_ratio = cfg.get("vertical_ratio", 0)
  
          self.tracker = DeepSORTTracker(
              budget=budget,
              max_age=max_age,
              max_iou_distance=max_iou_distance,
              matching_threshold=matching_threshold,
              min_box_area=min_box_area,
              vertical_ratio=vertical_ratio,
          )
  
      elif self.use_ocsort_tracker:
          det_thresh = cfg.get("det_thresh", 0.4)
          max_age = cfg.get("max_age", 30)
          min_hits = cfg.get("min_hits", 3)
          iou_threshold = cfg.get("iou_threshold", 0.3)
          delta_t = cfg.get("delta_t", 3)
          inertia = cfg.get("inertia", 0.2)
          min_box_area = cfg.get("min_box_area", 0)
          vertical_ratio = cfg.get("vertical_ratio", 0)
          use_byte = cfg.get("use_byte", False)
          use_angle_cost = cfg.get("use_angle_cost", False)
  
          self.tracker = OCSORTTracker(
              det_thresh=det_thresh,
              max_age=max_age,
              min_hits=min_hits,
              iou_threshold=iou_threshold,
              delta_t=delta_t,
              inertia=inertia,
              min_box_area=min_box_area,
              vertical_ratio=vertical_ratio,
              use_byte=use_byte,
              use_angle_cost=use_angle_cost,
          )
  
      elif self.use_botsort_tracker:
          track_high_thresh = cfg.get("track_high_thresh", 0.3)
          track_low_thresh = cfg.get("track_low_thresh", 0.2)
          new_track_thresh = cfg.get("new_track_thresh", 0.4)
          match_thresh = cfg.get("match_thresh", 0.7)
          track_buffer = cfg.get("track_buffer", 30)
          camera_motion = cfg.get("camera_motion", False)
          cmc_method = cfg.get("cmc_method", "sparseOptFlow")
  
          self.tracker = BOTSORTTracker(
              track_high_thresh=track_high_thresh,
              track_low_thresh=track_low_thresh,
              new_track_thresh=new_track_thresh,
              match_thresh=match_thresh,
              track_buffer=track_buffer,
              camera_motion=camera_motion,
              cmc_method=cmc_method,
          )
  
      else:
          # use ByteTracker
          use_byte = cfg.get("use_byte", False)
          det_thresh = cfg.get("det_thresh", 0.3)
          min_box_area = cfg.get("min_box_area", 0)
          vertical_ratio = cfg.get("vertical_ratio", 0)
          match_thres = cfg.get("match_thres", 0.9)
          conf_thres = cfg.get("conf_thres", 0.6)
          low_conf_thres = cfg.get("low_conf_thres", 0.1)
  
          self.tracker = JDETracker(
              use_byte=use_byte,
              det_thresh=det_thresh,
              num_classes=self.num_classes,
              min_box_area=min_box_area,
              vertical_ratio=vertical_ratio,
              match_thres=match_thres,
              conf_thres=conf_thres,
              low_conf_thres=low_conf_thres,
          )
  
      self.do_mtmct = False if mtmct_dir is None else True
      self.mtmct_dir = mtmct_dir
  
imports: import os
  import time
  import yaml
  import cv2
  import re
  import glob
  import numpy
  from collections import defaultdict
  import paddle
  from benchmark_utils import PaddleInferBenchmark
  from preprocess import decode_image
  import sys
  from det_infer import Detector, get_test_images, print_arguments, bench_log, PredictConfig, load_predictor
  from mot_utils import argsparser, Timer, get_current_memory_mb, video2frames, _is_valid_video
  from mot.tracker import JDETracker, DeepSORTTracker, OCSORTTracker, BOTSORTTracker
  from mot.utils import MOTTimer, write_mot_results, get_crops, clip_box, flow_statistic
  from mot.visualize import plot_tracking, plot_tracking_dict
  from mot.mtmct.utils import parse_bias
  from mot.mtmct.postprocess import trajectory_fusion, sub_cluster, gen_res, print_mtmct_result
  from mot.mtmct.postprocess import get_mtmct_matching_results, save_mtmct_crops, save_mtmct_vis_results
label_desc: Use image node_id 1 to create a new SDE_Detector object from inherited base classes: Detector with example: obj = SDE_Detector(model_dir, tracker_config, device, run_mode, batch_size, trt_min_shape, trt_max_shape, trt_opt_shape, trt_calib_mode, cpu_threads, enable_mkldnn, output_dir, threshold, save_images, save_mot_txts, draw_center_traj, secs_interval, skip_frame_num, warmup_frame, do_entrance_counting, do_break_in_counting, region_type, region_polygon, reid_model_dir, mtmct_dir)