Projects Goal: Tracking Snooker balls, generating 2D top view.
Environment: Jupyter Notebook, Python, OpenCV
Final result should look like this:
Output video - YouTube link
In this project I created a model which detects Snooker balls in a video and generates a 2D version of the table.
input video: YouTube link
For each frame:
-
Warp the perspective of the original frame.
-
Using HSV image to get color of table, mask the table, invert the mask to get image of masked objects on the table.
-
Finding contours of each object
-
Filtering contours based on their shapes and sizes.
-
Calculating average color inside of each contour to get each balls color.
-
Drawing a colored ball for each contour at its center on a 2D generated table.
- for designing the 2D table I just used cv2 functions
Circle
,Line
. markdowns according to this link
The model can track the balls and generate a 2D version of the table, although the final output is not perfect.
This is a simple model which does not know position of balls and does not remember balls locations, it only projects 'what it sees' no matter how many balls or what colors they are.
- more info and code can be found in the notebook -
TrackingSnookerBalls.ipynb