nwojke / deep_sort

Simple Online Realtime Tracking with a Deep Association Metric
GNU General Public License v3.0
5.27k stars 1.47k forks source link

Cap for fixed number of targets. #225

Closed WJRed closed 3 years ago

WJRed commented 4 years ago

Is there a way to cap the number of possible targets to give if that number is known (i.e. there are 5 people in this room) and reduce the accuracy necessary to output a target when partly occluded? Thanks for your great work.

studentbrad commented 3 years ago

There is. This can actually drastically improve your results. The reason being that it removes the need for tao which is the minimum score (cosine similarity) to be considered a match. If tao is not reached then a new track is spawned for that detection. If you know the number of individuals beforehand, then you can spawn that exact number of tracks and remove tao.

WJRed commented 3 years ago

Thanks for this Brad, looking forward to give it a try.

RedmWJ commented 3 years ago

@studentbrad Dear Brad, I'm afraid I haven't been so far able to find the tao you are mentioning. Any chance you could point me to where it resides? Thanks, Will.

studentbrad commented 3 years ago

@RedmWJ Sorry about that, I was using nomenclature (tao) from closely related literature. It is called max_cosine_distance here. https://github.com/nwojke/deep_sort/blob/280b8bdb255f223813ff4a8679f3e1321b08cdfc/deep_sort_app.py#L246 It is called max instead of min because of distance = 1 - cosine_similarity. https://github.com/nwojke/deep_sort/blob/280b8bdb255f223813ff4a8679f3e1321b08cdfc/deep_sort/nn_matching.py#L54

RedmWJ commented 3 years ago

No worries, thanks a lot for the quick response! Happy holidays!

danielcrane commented 2 years ago

@WJRed @studentbrad Did you guys have any luck with capping it to a fixed number of targets in a way that works nicely?

I'm a bit worried if I pre-specify the number of tracks then any incorrect detections would have a disproportionate effect on the tracking results.

Say for example if you're trying to track 10 players on a pitch, and at the start you happen to detect a member of the crowd or something instead of a player; if you had a fixed number of tracks this would cause the 10th player to never be picked up at all.

studentbrad commented 2 years ago

@danielcrane I have no tried it in the case of DeepSORT because better algorithms exist. But fortunately your concern should not be a problem here as long as the false detection is not persistent (does not occur very often). Because the maximum cosine distance here is 0, the algorithm will in fact pick the 10th player eventually as long as there is a frame that includes the 10th player without the false detection. If the false detection is persistent, you will need to modify the source. Hardcode the number of tracks and raise the maximum cosine distance to a reasonable number.

danielcrane commented 2 years ago

@studentbrad Thanks for your response.

May I ask which other algorithms you'd recommend in this kind of situation?

studentbrad commented 2 years ago

@danielcrane Unfortunately I don't think I can answer that due to legal reasons. I'm sorry that I can't help more 😞