I'm looking for an optical flow implementation to run on my web app in html5 canvas, but didn't found something immediately usable. If I choose to implement it by myself, is it be possible to achieve (near) real-time performance?
Or, since in the current setting, I actually just want to know the main optical flow is moving to the left or right, are there some easier algorithms I can use?
Optical flow is the pattern of apparent motion of image objects between two consecutive frames caused by the movement of object or camera. It is 2D vector field where each vector is a displacement vector showing the movement of points from first frame to second. Consider the image below (Image Courtesy: Wikipedia article on Optical Flow ).
It is used to find corners in the image and then calculate the corners’ motion vector between two consecutive frames. OpenCV has the implementation of Pyramid Lucas & Kanade with Shi-Tomasi algorithm improvement to calculate the Optical Flow.
Also, Optical Flow finds its application in Action Recognition tasks and real-time tracking systems. There are two types of Optical Flow, and the first one is called Sparse Optical Flow. It computes the motion vector for the specific set of objects (for example – detected corners on image).
We will create a dense optical flow field using the cv.calcOpticalFlowFarneback () method. Optical flow is the pattern of apparent motion of image objects between two consecutive frames caused by the movement of object or camera.
I made this little library which does (I hope) exactly what you are asking for.
A demo Which utilizes this library to control the ball by moving your hands.
I made a real time feature tracking that can generate sparse optical flow and point trajectories. It uses asm.js, so it runs faster on firefox (50ms per 320x240 frame - 1500 points)
www.ensta-paristech.fr/~garrigues/js_tracking/javascript_video_tracking.html
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