python - SORT Tracker - 参数设置

标签 python sorting computer-vision yolo

我在足球视频中遇到了一些与 SORT 跟踪器(卡尔曼滤波器和匈牙利算法的组合)与 YOLO v3 相结合相关的问题。 正如主论文中也提到的,SORT 在身份切换方面遭受了很多损失(换句话说,即使跟踪对象相同,ID 也会发生变化),而且在没有遮挡的情况下也是如此!我想知道是否可以通过校准参数 max_age (没有 id 分配可以通过的时间)和 max_hits 来(稍微)缓解这个问题。这些参数如何影响最终的跟踪?那么匈牙利语的 IoU 参数呢?非常感谢!

class Sort(object):
  def __init__(self,max_age=8,min_hits=3):
    """
    Sets key parameters for SORT
    """
    self.max_age = max_age
    self.min_hits = min_hits
    self.trackers = []
    self.frame_count = 0

  def update(self,dets):
    """
    Params:
      dets - a numpy array of detections in the format [[x,y,w,h,score],[x,y,w,h,score],...]
    Requires: this method must be called once for each frame even with empty detections.
    Returns the a similar array, where the last column is the object ID.

    NOTE: The number of objects returned may differ from the number of detections provided.
    """

    # prevent "too many indices for array" error
    if len(dets)==0:
      return np.empty((0,5))

    self.frame_count += 1
    #get predicted locations from existing trackers.
    trks = np.zeros((len(self.trackers),5))
    to_del = []
    ret = []
    for t,trk in enumerate(trks):
      pos = self.trackers[t].predict()[0]
      trk[:] = [pos[0], pos[1], pos[2], pos[3], 0]
      if(np.any(np.isnan(pos))):
        to_del.append(t)
    trks = np.ma.compress_rows(np.ma.masked_invalid(trks))
    for t in reversed(to_del):
      self.trackers.pop(t)
    matched, unmatched_dets, unmatched_trks = associate_detections_to_trackers(dets,trks)

    #update matched trackers with assigned detections
    for t,trk in enumerate(self.trackers):
      if(t not in unmatched_trks):
        d = matched[np.where(matched[:,1]==t)[0],0]
        trk.update(dets[d,:][0])

    #create and initialise new trackers for unmatched detections
    for i in unmatched_dets:
        trk = KalmanBoxTracker(dets[i,:])
        self.trackers.append(trk)
    i = len(self.trackers)
    for trk in reversed(self.trackers):
        d = trk.get_state()[0]
        if((trk.time_since_update < 1) and (trk.hit_streak >= self.min_hits or self.frame_count <= self.min_hits)):
          ret.append(np.concatenate((d,[trk.id+1])).reshape(1,-1)) # +1 as MOT benchmark requires positive
        i -= 1
        #remove dead tracklet
        if(trk.time_since_update > self.max_age):
          self.trackers.pop(i)
    if(len(ret)>0):

最佳答案

如果您提高 max_age,您将面临在丢失/离开场景的对象和进入上次看到区域的新对象之间混淆的风险。您应该使用此参数(也许提高一点)并降低卡尔曼的 IOU。这将创建更长、更稳健的跟踪,同时增加不同 ID 合并到一个跟踪中的风险。这种调整对于跟踪器的性能至关重要,并且高度依赖于数据。祝你好运:)

关于python - SORT Tracker - 参数设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57886239/

相关文章:

c# - Python .NET、多线程和 Windows 事件循环

python - Numpy - 通过测试相邻索引获取索引位置

javascript - 为什么 sort 给我随机排序(Knockout observable array)

java - ArrayList<Object> 的快速排序

c++ - 减少 Tesseract OCR 执行时间

python - 如何访问从 scipy.optimize.basinhopping (不是最小化)返回的 OptimizeResult 实例的 `success` 属性?

python - 为多索引数据框的每个级别查找最小值

Javascript:对多维数组进行排序

performance - 在向后传递过程中,caffe 是否也为学习率为零(lr_mult = 0)的层计算梯度?

opencv - 从纯彩色图像中提取特征