Step Five - Lucas Kanade flow estimator
We implemented a Lucas Kanade flow estimator in our second homework assignment
in this class, so I will not go into details of how it works. I would rather
discuss the integration of this algorithm with the rest of my code.
First of all, before the program starts the code needs to be initialized
with a region of interest. This means that a user must indicate the initial
position of the ball that is to be tracked at the beginning of the sequence.
While this might seem like cheating, you must keep in mind that this program
is not knowledge based and so it does not know anything about the initial
position of the ball. All it knows is the locations of light patches
of green that might be balls but it has no ability to distinguish one from
the other. This initial input allows the program to begin tracking the ball.
Another important note is that I track the images based on the edge images, not
on the original. Experiments I performed early on indicated that tracking
worked better with the edge images than with the original images, presumably
because there is less noise since the edges are highlighted and the movement
is more pronounced. For some of these videos, check out the outtakes in test1.
The Lucas Kanade code continues to loop until the error reaches a certain
level or the loop repeats itself 10 times.
Once a potential candidate position has been identified, let's compare it
to the ball mask to find a match in the next step.