Wouldn’t it be grear if we could use the soccer game that we all see played on TV for real time game analysis?
Abstract
Wouldn’t it be grear if we could use the soccer game that we all see played on TV for real time game analysis? Wouldn’t it help the referee if we could tell him at real time and with high level of accuracy that there was an offside in the soccer game?
After all, the offside situation depends on the location of the ball and the players in a given moment, the moment of a kick, and is not depends on the referee’s judgment
As part of developing a system to identify offside situation, there is a need to locate the ball and the player for each given moment
This project deal with locating the ball and tracking it, in a video film of soccer game.
Project Objective
- To develop a system aimed to detect the ball in a soccer game
- Keeping surveillance of the detected ball and on it’s position in the game, in the following frames
- Optimizing the algorithm in order to make it possible to use it in a real time
Various methods for detecting objects in a picture
Before starting to work we examined several methods for object detecting in a picture
Edge Detection
After running this algorithm, only the edges of the objects are left. We could try to search for a pattern of a circle – like the edges of the ball would be. The problem is that the size of the ball is something between 4 to 8 pixels, therefor there are a lot of objects matching the small circle template, what makes finding the ball very difficult
Thresholding
We could try finding the ball by its color.But, the white color is not unique to the ball, and it exists in many other objects. In addition, because of the small size of the ball, any “white noise” (few white pixels) can be considered as the ball
Templates
In this method we try to find object by matching it to a given template. After examening several differents soccer movies we noticed that the ball has a special template resulting from its high velocity on the field. The high velocity of the ball creates “spreading” and a unique pattern for the ball. Of course, we would have to take into account that the ball’s velocity is not fix, and therfore the pattern of the ball is not fix as well. We defined several templates to deal with this problem, each matching a given size and direction of the ball’s velocity.
Some techniques to help us finding an object in a picture
Before trying to locate an object in a picture, one should do a set of simple operation that will make life easier
We did 3 of such operations
1.Some of the objects in the picture are very easy to identify, and not needed for us. We would like to remove these objects from the picture so we can left with a picture containing less objects from the original one. We implementing this idea by removing all fixed (not moving) objects from the picture (Background picture subtraction)
2.The correlation between to sequential frames in a video movie is very high. In particular, the location of the ball in a given frame must be very near the location of the ball in the previous frame.
3.The high correlation expresses in the shape of the ball as well as in its location. When trying to locate the ball, we can use the already known pattern of the ball from the previous frame, by looking for the object that resemble the most to that pattern, and by that enlarging the chance to find the real ball.
Main stages
The basic principle of the algorithm is finding the ball by matching it to templates. The shape of the ball in picture is characterized by a “spreading” created by the high velocity of the ball. The first step is to define a relatively small set of templates that after that will be used for finding the ball.
Predefined templates
The algorithm uses a set of predefined templates.
Each template fit for a specific direction and velocity of the ball. The size of the ball is also taking into account in templates. It can be noticed that the templates fit for 3 different size balls, and for several direction and speed of the ball’s movement.


We can separate the problem into 2 cases
Finding the ball with no additional information form previous frames. In this case, we have to search for the ball all over the picture. In addition we have no information on how the ball may look like, so we have to use our predefined templates.
Finding the ball when we do have information from previous frames. In this case we already found the ball in the previous frame, so we have information about its location and shape. Therefore we can reduce the search to the near area of the location of the ball in the previous frame. We can also use its shape from the previous frame for finding the ball in the current frame.
Minimizing search area
In a soccer game (and actually in all real life games) the movement of the ball is sequential. The ball location is changing only in few pixels from frame to frame. Therefore, instead of looking for the ball all over the picture we can limit our search to the area in which the ball was found in the previous frame.
Using the template of the ball from the previous frame
The correlation between frames expresses in the shape of the ball as well. There is a high chance that the ball in the current frame is very much look like the ball in the previous frame. Therefore, we can use its template from the previous frame and not only the predefined templates for finding the ball in the current frame. In each frame, after finding the ball, we keep it template for using it in the next fame a search template.
Using the techniques we need to define the ball template in order to use it the next frame. This is done, by taking 7×7 square around the ball location from the picture. In the next frame we first try to find the ball using this 7×7 template.
One of the problems using this technique is the the offset in the ball location. As mentioned earlier the ball is very small but still not a single pixel fixture. The decision of the ball’s location includes noise due to the fact that there can be an offset of a pixel or two to the real center of the ball.
This problem is not severe in a single frame. But when dealing with the ball position in the next frame using the data from the pervious frame this offset can get more critical, for the offset in carried on to the next picture, and so on. In reality, what can happen is that the faster the ball is, the offset tends to increase, resulting, after a set of frames miss location of the ball although the ball was found in each of these frames.
The solution for this problem is to centralize the ball location. The procedure being done is taking the ball template and getting it’s brightest area. This point assumed to be the center of the ball and this ensure us that the template of the ball is really the one around the ball.
The flowing diagram describes the main steps of the algorithm

Results
In the picture you can see the ball course as find by the algorithm and drawn on a single picture

The results of the algorithm over 4 movies
The graph describe the success’s percentage in 4 movies, and for 4 different algorithms
Using black & white pictures and not using the template of the ball form previous frame
Using color picture and not using the template of the ball form previous frame
Using black & white pictures and the template of the ball form previous frame
Using color picture and the template of the ball form previous frame

From this graph it can be seen that the best results achieved for using color picture as well as the template of the ball from the previous frame.







