-
-
Notifications
You must be signed in to change notification settings - Fork 175
Description
Hi,
I've been using your SORT/yolov7 implementation, thanks for your work! There were 2 issues I ran in to with your current implementation.
The first is that it's mentioned in sort.py itself that update should be called even if there are no detections in the image. This is important for SORT to work properly if you have some frames where the detection is failing.
yolov7-object-tracking/sort.py
Lines 222 to 232 in 936097e
def update(self, dets= np.empty((0,6))): | |
""" | |
Parameters: | |
'dets' - a numpy array of detection in the format [[x1, y1, x2, y2, score], [x1,y1,x2,y2,score],...] | |
Ensure to call this method even frame has no detections. (pass np.empty((0,5))) | |
Returns a similar array, where the last column is object ID (replacing confidence score) | |
NOTE: The number of objects returned may differ from the number of objects provided. | |
""" |
However this is not actually done in the current implementation. In crowded scenes there will rarely be any frames with no detections, so this isn't a big issue, but for my use case I had a large number of frames with no detections.
This can easily be corrected by inserting a
else:
dets_to_sort = np.empty((0,6))
tracked_dets = sort_tracker.update(dets_to_sort)
here
yolov7-object-tracking/detect_and_track.py
Line 238 in 936097e
Another issue I ran in to is that the current implementation will fail if you have an input that results in more than 5005 unique tracks and you're using --colored-trk.
I fixed this by changing this from 5005 to 5003, since that is a prime number.
for i in range(0,5005): |
then just changing this
yolov7-object-tracking/detect_and_track.py
Line 207 in 936097e
rand_color_list[track.id], thickness=2) |
to rand_color_list[track.id % len(rand_color_list)], thickness=2)
, since after that many detections it won't really matter anyway that the same colours are picked again. Not the most elegant solution, but it works :).