def add(self, pts, ids=None, prune=True):
# Add only if valid and non-zero
if not len(pts):
return
# Retain valid points
valid = np.isfinite(pts).all(axis=1)
pts = pts[valid]
# ID valid points
max_id = np.max(self.ids) + 1 if len(self.ids) else 0
tids = np.arange(len(pts), dtype=np.int64) + max_id if ids is None else ids[valid].astype(np.int64)
# Add pts to track
for tid, pt in zip(tids, pts):
self.tracks_[tid].append(self.index_, pt)
# If features are propagated
if prune:
self.prune()
# Frame counter
self.index_ += 1
评论列表
文章目录