title: OpenCV image stitching leaves a blank region after the right boundary
body: <p>I had tried to run stitching with OpenCV 3.0; the result is good but also gave me a black blank area at right.</p>
  
  <pre><code>for (int i = 0; i &lt; best_matches.size(); i++)
  {
      //-- Get the keypoints from the good matches  
      FirstImageMatchPT.push_back(keypoints1[best_matches[i].queryIdx].pt);
      SecondImageMatchPT.push_back(keypoints2[best_matches[i].trainIdx].pt);
  }
  
  vector&lt;unsigned char&gt; match_mask;
  Mat MatchedImage = findHomography(SecondImageMatchPT, FirstImageMatchPT, CV_RANSAC);
  
  
  cv::Mat result;
  result = img_Right.clone();
  warpPerspective(img_Right, result, MatchedImage, cv::Size(img_Left.cols + img_Right.cols, img_Left.rows));
  
  cv::Mat half(result, cv::Rect(0, 0, img_Left.cols, img_Left.rows));
  img_Left.copyTo(half);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/w7twY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w7twY.png" alt="Left"></a> <a href="https://i.stack.imgur.com/x9PhL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x9PhL.png" alt="Right"></a>
  <a href="https://i.stack.imgur.com/0yAai.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0yAai.jpg" alt="Result"></a></p>
  
  <p>The first variable of 'findHomography' is the match points of the second (I mean, the right image) and the second one is the match points of the first (the left image).</p>
  
  <p>The reason why I did swapping the variables is if I run the code below, it cropped the left image and showed me only matched area of the left one plus the right image. (and even with a bigger blank area)</p>
  
  <pre><code>for (int i = 0; i &lt; best_matches.size(); i++)
  {
      //-- Get the keypoints from the good matches  
      FirstImageMatchPT.push_back(keypoints1[best_matches[i].queryIdx].pt);
      SecondImageMatchPT.push_back(keypoints2[best_matches[i].trainIdx].pt);
  }
  
  vector&lt;unsigned char&gt; match_mask;
  Mat MatchedImage = findHomography(FirstImageMatchPT, SecondImageMatchPT, CV_RANSAC);
  
  
  cv::Mat result;
  result = img_Left.clone();
  warpPerspective(img_Left, result, MatchedImage, cv::Size(img_Left.cols + img_Right.cols, img_Left.rows));
  
  
  cv::Mat half(result, cv::Rect(0, 0, img_Right.cols, img_Right.rows));
  img_Right.copyTo(half);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Cd8pI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cd8pI.jpg" alt="cropped image"></a></p>
  
  <p>Could you tell me how to make a right RoI for this? And how can I cut out that blank area automatically?</p>