title: implementing Image stabilization opencv, c++
body: <p>Today, I have lots of question and I need any kind of help, even in some parts of my question. 
  These questions are really urgent to be answered so please try the best with me. </p>
  
  <p>I'm working on Image Stabilization by using optical flow method. This step is done correctly and gave nice results, now I want to implement the stabilization for the video, which I have 2 ways to do that:
  First way:
  I have obtained the translation and rotation matrices between the features of the first frame and the next frame. Now, my supervisor suggest me to do like this; Make a canvas bigger twice than the original frame and copy the first frame in the middle. For each next frame, use the transformation I have obtained to calculate an offset and a rotation. Use these parameters and copy the next frame in its corrected position. This should produce a corrected video.</p>
  
  <p>So how to do that? and Please about help with functions in openCV if it's available.</p>
  
  <p>Second way, </p>
  
  <p>I was trying to do it my own way, which I was trying to get the corrected video by warping the image, which I have obtained the homography matrix but it doesn't work with the function <code>cvWarpPerspective().</code>anyway, is that correct what I'm doing here to get the stabilized image or what you suggest?</p>
  
  <p>Question:</p>
  
  <p>1- Homography matrix give negative values is that correct?</p>
  
  <p>2- As I mentioned above about the rotation and translation matrices which I have to make this equation in order to return the estimated feature in the second frame to its place in the first frame</p>
  
  <p>Y = rotation matrix* x + translation matrix </p>
  
  <p>which it give almost perfect results sometimes and another times give very awful results which I get negative values and much away from the location they supposed to be at, Why it's like that?</p>
  
  <p>Please answer what you can answer even if it's sub question</p>
  
  <p>Thank you so much.   </p>