Skip to content

SORT implementation and issue with videos with a large number of unique tracks #37

@C-van-der-Laan

Description

@C-van-der-Laan

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.

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

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

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 :).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions