Automatic recognition of "Offside" situation in soccer game

by Edo Yichie and Eitan Schley
Supervised by Guy Gilboa


Offside situation is a common offence in a Soccer game. The Offside rule brings much more tactics both to the defensive and the offensive sides. However, Offside detection is a complex task for the human eye due to the fast pace of the game, and therefore is subject to many false judgment cases. Today, Thanks to the advances of technology, an Automatic recognition of an Offside situation is desired. This project is part of several projects already done in this area. Prior projects have implemented tracking of players, mapping of field coordinates and tracking of the ball. This project is divided into two parts. First, we'll try to implement ball detection in a different way than before, using PCA analysis. In the second part, We'll perform an integration with the previous projects of the coordinates mapping and the players tracking in order to create a system that will be able to determine if and when an offside offence has been made.

Part I - Ball detection

The problem:

The system gets a sequence of frames, and must detect and track the ball successfully with minimum false detections and misdetections. Some difficulties in the detecting the ball are:
  • Being able to detect the ball successfully among all other objects on the field.
  • Overcoming occlusions and merges with other objects.

The solution:

First, we had to implement a ball detection in a rather simple case, when the ball is not occluded by any other object. In order to do that, we used PCA analysis. After extracting hundreds of balls from sample movies, we applied PCA on them. That gave us the information we needed on the behavior of the ball. The Detection of the ball itself is done by measuring the MSE of the suspicious objects with their representation in a few principle components of the ball PCA.

As seen in the graph above, the ball has the lowest MSE from the principle components representation.

In order to track the ball, we defined several states in which the ball can be in: Ball Location is unknown, Ball location is known, Ball is with player, Ball is near a player.

State 0: Ball Location is unknown
When the algorithm doesn't locate a ball in the frame (All suspicious object has a high MSE).

State 1: Ball Location is known
If the ball was found in the last frame, We know that it must be in the vicinity of the last position, and therefore we reduce our search to that area alone. If the ball wasn't found, we estimate it's position and if we find there an object, we assume the ball merged with it. If no object was found, we say we lost the ball.

State 2: Ball is with player
This state means that the ball was lost in the area of this player. So we scan the area of that player for the ball. If the ball was found, we go to state 3, if not we stay as this state, until "Timeout", then we say that the ball is not with this player, and we go back to state 0.

State 3: Ball is near a player
We reach this state only after the ball was detected after lost close to a player. We have this state because many times when the ball is with a player it is occasionally detected. But if it's not detected again, we want to keep our tracking on the player. If the ball is found again, we go to state 1, if not we go to state 2. This state resets the "timeout" of state 2.


These are the results of 4 representative movies.

Frames without a ball were disregarded, unless a false detection occurred.
As seen by the graph, the detection of the ball ranges from 80% above.
False Detection (Detecting a different object as the ball) is a rare case! But misdetection of the ball is a bigger obstacle for the system.

Part II - Offside detection

The problem:

Given a ball and player position on the field, decide when an Offside offense has been made. There are several difficulties in deciding when an Offside offence was actually made:
  • When the ball is kicked.
  • By which player the ball was kicked.
  • Is there a player in Offside position?

The solution:

In order to decide when the ball was kicked, we need to look for a sudden change in its speed, i.e. its acceleration.
Acceleration calculation requires the position in 3 consecutive frames, which means that the detection of the kick comes in a 2 frames delay from the actual kick.

In order to decide in an Offside offence was made, we used several flags:
  • Possible - do we have enough information to decide. That means, do we know where to ball is and who is the closest player to the goal.
  • Off_Player - Is there an offensive player in Offside position.
  • Off_Ball - Is the ball in a position where there's a chance of an Offside to occur. That means, is an Offensive player is in charge of the ball.
  • Kick - Was the ball kicked?
This is the Offside detection system:

Normal state is when there is no risk of an Offside offense to occur, or it is not possible to decide.
When there is a player in Offside position and there's an offensive player in charge of the ball, there is a risk of an Offside and we go to "Offside state".
If in "Offside state" the ball is kicked the system pause the game for an Offside offense has been made!


In this project we detected the ball in a soccer game and built a system that checks for an Offside offence in the game using means of image processing.
Although the detection of the ball gave good results, there are still many problems using image processing in detecting Offside situation. These problems come mainly from Occlusions of the ball and players and the difficulty in deciding who has the ball.
This project proves that it is possible to create a system that will detect Offside situation successfully, although there is still much more improvements that could be done to such a system, one very important improvement could be adding more observation angles to the game, to minimize occlusions and false detections.


We are grateful to our project supervisor Guy Gilboa and the Vision and Image Science Lab staff for their support and guidance.
We are also grateful to the Ollendorff Minerva Center Fund for supporting this project.

Related documentation