Processing multiple frames
Till now we saw examples of modification and drawing video frames just like single images. Deeper processing should involve analysis of the several frames.
If we compare two successive frames, we can find the direction and velocity of motion for each frame pixel. Such a vector field is called optical flow. It has many uses in video, graphics, and computer vision. Optical flow computation is a nontrivial task of computer vision, and we will learn to do it in Chapter 9, Computer Vision with OpenCV.
Another idea is to bufferize a number of frames and then draw parts of the frames in different parts of the screen. The famous video effect called slit-scan or time displacement is based on this principle. In effect, horizontal lines of the resulting image are built from horizontal lines of several successive frames. Often, bottom lines are taken from older frames, and top lines are made from the newest frames. So if the object was moved horizontally in the original video...