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

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

Open
C-van-der-Laan opened this issue May 26, 2023 · 2 comments

Comments

@C-van-der-Laan
Copy link
Contributor

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

@RizwanMunawar
Copy link
Owner

Thanks @C-van-der-Laan! Can you please send me a pull request, you can then become a contributor to the repository.
Otherwise, I will do changes on my own. 👍🏻

@C-van-der-Laan
Copy link
Contributor Author

Alright done! Realized that since the update method had a default argument the dets_to_sort = np.empty((0,6)) wasn't even needed.

RizwanMunawar added a commit that referenced this issue Jun 18, 2023
[ISSUE #37] fix sort no dets & fix large N trks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants