Skip to content

Commit

Permalink
Merge pull request #1192 from Justin900429/master
Browse files Browse the repository at this point in the history
Improvement for BoT-SORT
  • Loading branch information
mikel-brostrom authored Nov 13, 2023
2 parents bd41c65 + 296d8ae commit 72c28b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 3 additions & 7 deletions boxmot/motion/cmc/sof.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,16 @@ def apply(self, img, dets):
return H

# sparse otical flow for sparse features using Lucas-Kanade with pyramids
# calculate new positions of the keypoints between the previous frame (self.prev_img)
# and the current frame (img) using sparse optical flow (Lucas-Kanade with pyramids)
try:
matchedKeypoints, status, err = cv2.calcOpticalFlowPyrLK(
next_keypoints, status, err = cv2.calcOpticalFlowPyrLK(
self.prev_img, img, self.prev_keypoints, None
)
except Exception as e:
LOGGER.warning(f'calcOpticalFlowPyrLK failed: {e}')
return H

# calculate new positions of the keypoints between the previous frame (self.prev_img)
# and the current frame (img) using sparse optical flow (Lucas-Kanade with pyramids)
next_keypoints, status, err = cv2.calcOpticalFlowPyrLK(
self.prev_img, img, self.prev_keypoints, None
)

# for simplicity, if no keypoints are found, we discard the frame
if next_keypoints is None:
return H
Expand Down
4 changes: 4 additions & 0 deletions boxmot/trackers/botsort/bot_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def __init__(
appearance_thresh: float = 0.25,
cmc_method: str = "sparseOptFlow",
frame_rate=30,
fuse_first_associate: bool = False,
):
self.tracked_stracks = [] # type: list[STrack]
self.lost_stracks = [] # type: list[STrack]
Expand All @@ -222,6 +223,7 @@ def __init__(
)

self.cmc = SparseOptFlow()
self.fuse_first_associate = fuse_first_associate

def update(self, dets, img):
assert isinstance(
Expand Down Expand Up @@ -288,6 +290,8 @@ def update(self, dets, img):
# Associate with high score detection boxes
ious_dists = iou_distance(strack_pool, detections)
ious_dists_mask = ious_dists > self.proximity_thresh
if self.fuse_first_associate:
ious_dists = fuse_score(ious_dists, detections)

emb_dists = embedding_distance(strack_pool, detections) / 2.0
emb_dists[emb_dists > self.appearance_thresh] = 1.0
Expand Down

0 comments on commit 72c28b9

Please sign in to comment.