CS223B - Intro to Computer Vision Final Project

Step Six - Comparison of LK prediction to ball mask

Now that we have predicted a possible location of the ball, we compare it to the ball mask that shows places where the ball could be based on color segmentation. This helps in cases where the ball moved by amount more than what optical flow algorithms can follow. In these cases the optical flow algorithms will simply give an answer that is near the previous location, but not near the object we are tracking. To try an avoid this pitfall, we move to the point that is closest on the ball mask image where we think the ball might actually be.

You can see the potential problem quite clearly in a video that does not do this correction. When the player kicks the ball ahead quickly, the optical flow code does not respond and so it begins to track other things that resemble the ball (like a player's head). This video only shows edges because that's what the Lucas Kanade algorithm from step5 works on.

There are occasions where the ball is occluded, however, and so the nearest white patch might be quite far away. We don't want our algorithm to be distracted by this extra noise. Thus, I assume that the ball can't move further than a certain amount in each frame and so I only look for white patches within a specific radius (45 pixels). If no white patches are found within this radius, then the estimate of Lucas Kanade code is what is used as the final ball location.

This decision has a potential negative side-effect. If for some reason the ball is lost during tracking, then it is harder to regain track of the ball since it must appear within the specified radius of the previous prediction.

Finally, let's move on to step7.