Skip to content

krzywilk/wangiee-dynamics-engineering

Repository files navigation

Table tennis entities detection

animated

Introduction

The algorithm is designed to detect the elements of table tennis gameplay. The test dataset contains videos recorded from a static position. The camera is always behind the back of one of the players.

Table tennis entities detection is based only on the classic computer vision and clustering algorithms.

Scripts execution

Installation Due to the use of only image operations and unsupervised clustering algorithms, the GPU is not required. To prepare the environment, just install the libraries from requirements.txt.
Running Temporarily there is no specific script configuration. An example usage is in the main.py file.

Output

The result of the algorithm are points representing the coordinates of corners of the table, and the players bounding boxes.

Top player Bottom player
Alt text Alt text

Alt text

Algorithm steps details

Table corners detection
Table contours detection

Table lines detection

Lines detection

Table lines detection is based on the Probabilistic Hough Transform. Successive frames are transformed and detected lines are saved in the mask. When iteration is done, the mask contains the table lines and excess lines detected outside the table.

animated

Choosing the right contours

On the finished mask, connected components are detected, and the component closest to the center of the image is selected.

animated

Table mask corners detections

Lines theta and rho calculation

animated

General line detection

Mask lines detection is based on Hough Line Transform.

animated

Lines filtering

The algorithm filters redundant lines which rho and theta values ​​are close to each other.

animated

Lines clustering

The lines are clustered due to the angle of inclination. Clustering is done by the DBSCAN algorithm. Outlier lines are removed from lines list.

animated

Lines intersection on a table

animated

Intersections

All points of intersection between the horizontal and vertical lines are calculated basis on theta and rho of lines.

animated

Intersections clustering

The Intersections are clustered due to the position on the Cartesian plane. Clustering is done by the DBSCAN algorithm.

animated

Intersections clusters centroids

Intersection cluster centroids are calculated as the average of all existing points in the cluster.

animated

Players detection

Difference segmentation masks

Due to the fact that table tennis is very dynamic, it is possible to create a mask of the differences between the frames to target the most dynamic elements of the image

animated

Most dynamic elements detection

Regions of interest

Thanks to the preserved perspective, it is possible to separate the parts of the image where the lower player and the upper player can be located, the detection takes place separately on both parts of the image.

animated

Players difference masks

Separate difference mask elements are detected using the connected components algorithm. The largest masks on separate regions of interest are considered player masks.

animated

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages