In this article, we continue our exploration of Tennis Analytics with Computer Vision by focusing on tracking and team detection.
For team detection, the players are differentiated based on the color of their jerseys. The background color is masked so that the number of dominating colors in the pixel does not consider the background color.
For player and ball tracking, the SORT (Simple Online and Realtime Tracking) algorithm by Alex Bewley is utilized. The Sort Class is instantiated and included in the object detection loop to update it every frame.
After tracking, the bounding boxes and IDs of the players are visualized by drawing them on the frame.