CS223B - Intro to Computer Vision Final Project

Test#2 - A free kick

My second test involved a free kick because this provides a difficult scenario to track the ball. For one, the ball is traveling extremely fast, and is very blurred in the middle of its flight. In addition, there is some occlusion and deflection when the ball goes through the players, which makes things difficult for a computer vision algorithm.

Video:


Original Footage. Pause it in the middle to see the blurriness of the ball.

Final Results. The program successfully tracks the ball from kicker to goalie. This result was achieved only after the code was made more robust (see "Outtakes" section)

Outtakes:

As I had suspected, the code that worked for Test 1 failed miserably on this scenario. Here is a summary of some of the modifications that I made to the code to make it more robust. I also included videos to chronicle the problems along the way.


This footage is simply the output of the algorithm from test 1. However, the ball is so blurred that the algorithm does not even see it go by. Pause the movie when the ball is in the air to verify that the ball is difficult to see in midflight from a frozen frame. Note that the initial location was set to be somewhere in the middle in this test so that the ball would pass near it.

The results from the first video required me to improve the visibility of the ball. To do this, the file that contains the color segmentation data for the ball was updated and more shades of green were added. Although the ball appears white to us on the screen, it really is a light shade of green and becomes even greener as it blurs out. After this has been added, the program is now "seeing" the ball as it flies by and it actually follows it for a frame before it loses it again.

I added still more shades of green to the ball color data file to ensure that the program picks up the ball as it whizzes by. However, now the problem is that it finds too many "white" areas and so now even the player's foot matches the ball during the color segmentation. So the instead of following the ball, the algorithm follows the closer of the two white objects and follows the players foot.

Since it seemed that every player had a small outline around them that seemed to match the color of the ball layer, I had to add an extra layer which I called "player." This layer consists of darker colors and the program uses it to mask off the ball layer. This eliminates the problems we were seeing in the previous video with the ball sticking to players (for the most part). However, as you can see here, the ball is still too faint at some points in its trajectory and so the program still loses it midflight.

To counteract the fact that it was losing the ball when it moved so quickly, I added code to "predict" where the ball would be in the next frame by determining how far it had moved from the previous frame and made the assumption that it would move by the same amount in the next frame. This initially had a tragically humorous result, as can be seen in this video. This test was initialized at the incorrect starting position and the initial jump that the program makes to get to the ball causes it to continue down that path, which leads it off the screen before the player has even kicked the ball. I later added a safety measure that limited the distance that the prediction would cover.

Comments:

After making these modifications to the algorithm, the final results shown above were obtained. In the resulting movie, you can see that the program loses the ball behind the blocking players for a frame or two. The ball begins to pop out from behind them, but it takes the algorithm a frame or two to catch it again. Overall, the tracking of the ball during this test is fairly impressive. Once modified, the basic algorithm was not changed again for the remainder of the tests.

Go on to the next test.