As we own quite powerful process capabilities, it’s possible to put a webcam pointing to the ground and to track points in order not to drift along x and y. In order to do this, we could use the Lucas-Kanade algorithm. Here are the main features that would be used. We have two pictures in gray scale, A and B, taken at different times separated of δt. We begin by obtaining the derivative of the error in comparison with the move:
Then, we apply a Taylor development (order 1) around the move [0, 0] (valid if we consider move is small, and we will admit it):
From now, we can briefly stop computations to consider some facts. for any (x, y) belonging to the window:
With those notations, we obtain:
Finally, a slightly transformation gives us:
If we use:
and:
we can rewrite the previous equation:
As, let us not forget about it, the goal is to cancel out error’s derivative, we get:
G is invertible if gradient of A is defined, i.e if the window is contained into the picture, and if we have a high enough contrast into the window (see last part about good pixels choice). We have now a way to compute a ‘most coherent’ movement vector, which allows us to transit from A to B in a given window for a given pixel. Previous computations are just a single iteration of the algorithm. We can consolidate the result by applying them several times, until, for example, the new found norm of movement is less than a chosen epsilon.
and then we compute:
We can see now how useful it was to compute gradient of A rather than gradient of B because we won’t have to compute it again through iterations.
We saw in first section that using windows wasn’t enough to get a good compromise between process speed and large moves detection. We take m pyramidal levels (often 3) and we apply the whole algorithm at each level from Lm to 0.
Here is a small illustration of the procedure:
Here we want to track Lena’s nose from the first picture to the second one.
We use a 4 levels (Lm = 3) pyramidal form, and in the end we will just have to sum rescaled moves to get the whole one.
We can choose the best pixels to be followed by thinking about the use we want to have with them.
This procedure is quite heavy, mostly because we should repeat it for each new image couple. That is why we could for example keep tracked pixels from a image to another or always keep the same reference picture and its pixels if we just want to know how far we moved from a given spot. We saw the version of Lucas and Kanade algorithm which is implemented in OpenCV library. This algorithm is easy to understand and easily customizable in order to be adapted to the most exigent embedded systems. Pyramidal Implementation of the Lucas Kanade Feature Tracker http://copterix.perso.rezel.net/?page_id=58 http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_video/py_lucas_kanade/py_lucas_kanade.html#lucas-kanade |