I am working on optical flow, and based on the lecture notes here and some samples on the Internet, I wrote this Python code.
All code and sample images are there as well. For small displacements of around 4-5 pixels, the direction of vector calculated seems to be fine, but the magnitude of the vector is too small (that's why I had to multiply u,v by 3 before plotting them).
Is this because of the limitation of the algorithm, or error in the code? The lecture note shared above also says that motion needs to be small "u, v are less than 1 pixel", maybe that's why. What is the reason for this limitation?
The Lucas-Kanade optical flow algorithm is a simple technique which can provide an estimate of the movement of interesting features in successive images of a scene. We would like to associate a movement vector (u, v) to every such ”interesting” pixel in the scene, obtained by comparing the two consecutive images.
Optical flow is a vector field between two images, showing how the pixels of an object in the first image can be moved to form the same object in the second image . It is a kind of correspondence learning, because if the corresponding pixels of an object are known, the optical flow field can be calculated.
It assumes that the flow is essentially constant in a local neighbourhood of the pixel under consideration, and solves the basic optical flow equations for all the pixels in that neighbourhood, by the least squares criterion.
The advantages and disadvantages of Lucas kanade method is: Advantages –this method is easy compare another method, very fast calculation and accurate time derivatives. Disadvantage - errors on boundaries of moving object [10].
@belisarius says "LK uses a first order approximation, and so (u,v) should be ideally << 1, if not, higher order terms dominate the behavior and you are toast. ".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With