Ask Your Question

motion COMPENSATION between 2 frames? [closed]

asked 2016-01-04 11:51:17 -0500

Cabezon667 gravatar image

updated 2016-01-05 06:38:19 -0500

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.


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.

image description

edit retag flag offensive 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


What exactly is a compensated frame?

FooBar gravatar imageFooBar ( 2016-01-05 02:35:29 -0500 )edit

Hi, I updated my question.

Cabezon667 gravatar imageCabezon667 ( 2016-01-05 06:38:50 -0500 )edit

it's still unclear.

berak gravatar imageberak ( 2016-01-05 08:11:04 -0500 )edit

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.

Cabezon667 gravatar imageCabezon667 ( 2016-01-05 08:25:15 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-01-12 06:46:59 -0500

tomnjerry gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-01-04 11:51:17 -0500

Seen: 988 times

Last updated: Jan 12 '16