title: HOW TO use Homography to transform pictures in OpenCV?
body: <p>I've two pictures (A and B) slightly distorted one from the other, where there are translation, rotation and scale differences between them (for example, these pictures:)</p>
  
  <p><img src="https://i.stack.imgur.com/nqLS8.png" alt="ORIGINAL LENA">
  <img src="https://i.stack.imgur.com/v5uD4.png" alt="DISTORTED LENA"></p>
  
  <hr>
  
  <p>Ssoooooooo what I need is to apply a kind of transformation in pic B so it compensates the distortion/translation/rotation that exists to make both pictures with the same size, orientation and with no translation</p>
  
  <p>I've already extracted the points and found the Homography, as shown bellow. But I don'know how to use the Homography to transform <code>Mat img_B</code> so it looks like <code>Mat img_A</code>. Any idea?</p>
  
  <pre><code>//-- Localize the object from img_1 in img_2
  std::vector&lt;Point2f&gt; obj;
  std::vector&lt;Point2f&gt; scene;
  
  for (unsigned int i = 0; i &lt; good_matches.size(); i++) {
      //-- Get the keypoints from the good matches
      obj.push_back(keypoints_object[good_matches[i].queryIdx].pt);
      scene.push_back(keypoints_scene[good_matches[i].trainIdx].pt);
  }
  
  Mat H = findHomography(obj, scene, CV_RANSAC);
  </code></pre>
  
  <p>Cheers,</p>