First I had to learn about the physics of pools. Angles are only perfect under specific conditions of hitting force, speed, cue or ball hit position, etc. As this video is made by a human, not all scenarios are perfect, and there is where we have magic.
I used a contour approach, finding contours of Stick, Cue and Ball in specific frame. Then making math calculations and projections I am able to tell if the ball is inside one of the 6 holes in the table. If that is the case then the ball is inside and will drar in green else it is not and will draw in red.
For finding contours I had to tweek Canny variables and Kernel size in order to get the all contours, then I filter to keep only with the ones i was interested in. Holes and lower edge will have the same coordinates in every case.

Leave a Reply

Your email address will not be published. Required fields are marked *