Personal project still in development, still working on pages layout and functionalities.
This little project will detect offsides in an image input by the user
Here is an example of an input image:
Currently, after the detection we get the detected players on the image:
After removing players that are not on the field (managers, side referees, etc...), we get this bird eye view of the field with the players positions, and the lines that represent the offside positions in both sides:
We now can go back to the original image and draw the offside lines:
- Clone the repository
- Download the weight file, this is essential for the program to work link here. It's from the famous YOLO project. And put it in same directory as the app.py file.
- Run the flask server using the command
python app.py
(python3 app.py
on Linux) in the terminal and go to the web page - Further instructions on the web page when launching the program
My idea is to work on a still image of a TV broadcast of a football match following these steps:
- calibrate the camera to the field to get 3d world coordinate
- get position of the players
- identify the players of different teams
- check if a player is on an offside position
I will discuss each step separately
The input images should be a single frame from a football game broadcast like the one on the top. The bigger the field of view the more accurate the detection will be.
One of the features that can be added is possibility of using a video, as such that the offside lines will be drawn in real time
On a single frame, this step is quite easy, the user will need to click on 4 points on the field in the input image, and then click on the corresponding points in a field map. This is a calibration step, which will be used to get the 3d world coordinates of the players.
Usually, players have at least one foot on the ground, So, their positions on the field is the position of the feet. There are 2 ways to get the position of a player:
- Manually click the feet of all the players
- Automatically getting the feet positions
Still not implemented
The position of the ball is very important, as it will be used to check for offside. Still not implemented
After all these steps, this gonna be the easiest one, we will just compare the positions of players of each team. For now, I will not study the edges cases, like goalkeeper before last defender, or ball in other center of half of the field.
To learn more about the offside rules, you can check this.
I would really like to hear from you, if you have any questions or suggestions.