Computing the optical flow
Optical flow (also known as optic flow) is the pattern that appears in the motion of objects in a video (live or recorded). Pay attention to the word appearance in the previous sentence. This means that if the observer (in our case, the camera) is in motion, then the objects in the scene are also considered to be moving, even if they are static. This is known as relative motion. In brief, the optical flow highlights the relative motion in the video. OpenCV has implementations for many of the functions that can compute the optical flow. The cv2.calcOpticalFlowFarneback()
function computes the optical flow with the dense
method. This means that it computes the flow for all the points. This function implements the Gunner Farneback algorithm.
NOTE:
You can read more about the Gunner Farneback argument at the following URL:
http://www.diva-portal.org/smash/get/diva2:273847/FULLTEXT01.pdfTwo-Frame
Let's see how we can compute the optical flow...