0

Hi I am trying to stitch some images without using the stitch class provided by opencv. But, the output is quit unexpected. I will explain it with the input and output image.

input1 enter image description here

input2enter image description here

expected outputenter image description here

real output enter image description here

I think something is wrong with my ROI copying. anybody please help !!!

My code for stitching part is as follows-

std::vector< Point2f > points1,points2;
        for( int i = 0; i < matches1.size(); i++ )
           {
            points1.push_back( keypoints_input1[matches1[i].queryIdx ].pt );
            points2.push_back( keypoints_input2[matches1[i].trainIdx ].pt );
           }
        /* Find the Homography Matrix for current and next frame*/
         Mat H1 = findHomography( points2, points1, CV_RANSAC );
         /* Use the Homography Matrix to warp the images*/
        cv::Mat result1;
        warpPerspective(input2, result1, H1, Size(input2.cols+150, input2.rows+150),     INTER_CUBIC);
        Mat stitch_1(Size(input2.cols+150, input2.rows+150),CV_8UC3);
        Mat roi1(stitch_1, Rect(0, 0,  input1.cols, input1.rows));
       Mat roi2(stitch_1, Rect(0, 0, result1.cols, result1.rows));
    
   
       input2.copyTo(roi1);
    result1.copyTo(roi2);

Can anybody tell me where I am going wrong ? thanks.

Edit: input1(640,360) and input2(790,510) are of different size.

Community
  • 1
  • 1
MMH
  • 1,676
  • 5
  • 26
  • 43

1 Answers1

0

I hope that this example helps you.

It's interesting to test on different images.

EDIT:

try this code:

Mat stitch_1(Size(input2.cols*2+ input1.rows,input2.rows*2),CV_8UC3);
Mat roi1(stitch_1, Rect(0, 0,  input1.cols, input1.rows));
Mat roi2(stitch_1, Rect(0, 0, result1.cols, result1.rows));
result1.copyTo(roi2);
input1.copyTo(roi1);
imshow("final", stitch_1);
Y.AL
  • 1,808
  • 13
  • 27
  • thanks for your answer, but the input images in the link are of same sizes. I tried that code as well, but it doesn't work. – MMH Feb 25 '14 at 09:41
  • sorry, but it has similar output, with a lager black area. thanks – MMH Feb 25 '14 at 10:07