# motion COMPENSATION between 2 frames? [closed]

Hello, my question is simple. I want to know how I could get a frame as the result of compensation between 2 images.

I understand functions as goodFeaturesToTrack() and cvCalcOpticalFlowPyrLK(), but my question is to OBTAIN the result of a compensated frame, not the estimation. I mean, to obtain the compensated frame between 2 frames.

I will appreciate any help, I'm newbie in OpenCV.

UPDATED:

To reply the question, a compensated frame is the result of the prediction between 2 frames, and is used to reduce the data for video processing. In the end, the substraction between 2 frames will give us a 'error frame' and this one will be encoder for transmission. The result between a frame and a compensated frame will give us a less error frame, that will improve the PSNR and reduce the bit-rate.

Im putting an example of my work in MatLab, that I want to implement in OpenCV. edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by Cabezon667 close date 2016-01-15 19:40:26.900994

I have frame1 and frame2, and Im trying to compensate the image and I Obtained the the 3rd frame. Is still unclear? I'm separating the 2 images into macroblocks and then I compare each macroblock, so I obtain compensate frame. Still unclear? I dont know if its allowed to put MatLab code to check my process.

Sort by » oldest newest most voted I have dealt with similar problem before. Here is what you can do: 1) First, extract two consecutive frames (which I guess you already have) 2) Calculate the optical flow of the frames. Optical flow basically uses image matching algorithms like SIFT etc to know the location of object in frame 2 based on its features in frame 1. Thus, it has the displacement of the object from its position in frame 1 to its new position in frame 2. So, optical flow helps us calculate the magnitude of displacement and the direction in which displacement occurred for of all the points in the frame 2 as compared to frame 1. 3) Now, we can interpolate the frame between the two frames using the simple algebra rule. Interpolation is predicting the position of object in a frame located between two given frames.

There are inbuilt functions to calculate the optical flow i.e motion estimation between two frames. You can find more details about optical flow function provided by OpenCV here.

With this function, implementing motion estimation and generating interpolated frame should not be a problem. I hope this helps.

more

Official site

GitHub

Wiki

Documentation