Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix enumerate call #1049

Merged
merged 5 commits into from
Mar 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions supervision/tracker/byte_tracker/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,23 @@ def callback(frame: np.ndarray, index: int) -> np.ndarray:
iou_costs = 1 - ious

matches, _, _ = matching.linear_assignment(iou_costs, 0.5)
for i, idet, itrack in enumerate(matches):
for i, (idet, itrack) in enumerate(matches):
if i == 0:
final_detections = detections[[idet]]
final_detections.tracker_id[0] = int(tracks[itrack].track_id)
if final_detections.tracker_id is None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can tracker_id be None?

final_detections.tracker_id = np.asarray(
[int(tracks[itrack].track_id)]
)
else:
final_detections.tracker_id[0] = int(tracks[itrack].track_id)
else:
current_detection = detections[[idet]]
current_detection.tracker_id[0] = int(tracks[itrack].track_id)
if current_detection.tracker_id is None:
current_detection.tracker_id = np.asarray(
[int(tracks[itrack].track_id)]
)
else:
current_detection.tracker_id[0] = int(tracks[itrack].track_id)
final_detections = Detections.merge(
[final_detections, current_detection]
)
Expand Down