code: def update_center_traj(self, mot_res, max_len):
      from collections import deque, defaultdict
  
      if mot_res is not None:
          ids = mot_res["boxes"][:, 0]
          scores = mot_res["boxes"][:, 2]
          boxes = mot_res["boxes"][:, 3:]
          boxes[:, 2] = boxes[:, 2] - boxes[:, 0]
          boxes[:, 3] = boxes[:, 3] - boxes[:, 1]
      else:
          boxes = np.zeros([0, 4])
          ids = np.zeros([0])
          scores = np.zeros([0])
  
      # single class, still need to be defaultdict type for ploting
      num_classes = 1
      online_tlwhs = defaultdict(list)
      online_scores = defaultdict(list)
      online_ids = defaultdict(list)
      online_tlwhs[0] = boxes
      online_ids[0] = ids
  
      if mot_res is not None:
          for cls_id in range(num_classes):
              tlwhs = online_tlwhs[cls_id]
              obj_ids = online_ids[cls_id]
              for i, tlwh in enumerate(tlwhs):
                  x1, y1, w, h = tlwh
                  center = tuple(map(int, (x1 + w / 2.0, y1 + h)))
                  obj_id = int(obj_ids[i])
                  if self.center_traj_retrograde is not None:
                      if (
                          obj_id
                          not in self.center_traj_retrograde[cls_id]
                      ):
                          self.center_traj_retrograde[cls_id][
                              obj_id
                          ] = deque(maxlen=max_len)
                      self.center_traj_retrograde[cls_id][
                          obj_id
                      ].append(center)
  
file_path: PaddleDetection/deploy/pipeline/ppvehicle/vehicle_retrograde.py
imports: import numpy
  import math
label_desc: Use image node_id 2 for calling the VehicleRetrogradeRecognizer obj's underlying member method code with example usage: obj.update_center_traj(mot_res, max_len) without return types