Now that you have seen both the methods, it is time to try and reconstruct the first frame of the pair, using the second one and the optical flow field. We will try to accomplish that by a straightforward method called interpolation. This method actually tries to estimate unknown data, given a known set of data. In our case, the known set of data comprises the pixel values in the second frame of the pair and the motion vectors. We will repeat the same procedure for both the Horn-Schunck and Lucas-Kanade methods.
We start by loading our video:
>> clear all; >> videoObj = VideoReader('atrium.avi'); % Open video
Now, we'll create two system objects, one for each optical flow method:
>> ofHS = vision.OpticalFlow('ReferenceFrameDelay', 1,... 'Method','Horn-Schunck', 'OutputValue', 'Horizontal and vertical components in complex form'); % Horn Schunck method >> ofLK = vision.OpticalFlow('ReferenceFrameDelay', 1,... 'Method...