I\'m a beginner programmer and just started using OpenCV. I want to stitch together 2 images using OpenCV\'s stitching.cpp Sample program When I attempt to stitch the images, I
My guess after looking at above images is that the images which you have captured are too difficult to infer reliable matching. As you may know, stitching consists of:
You are getting wrongly stitched images in one case, and the stitching is perfect for another pair of images, indicates that you have got the homography wrong. Homography depends on matched keypoints, thus that is where the real fault lies.
In the first set of images you have posted, both consist of keyboard. I would not be surprised if a keypoint detection and matching algorithm like SIFT matches the right-shift in the first image with the left-shift of the second computer in the second image. This is totally wrong and will mess up the homography. Similarly, the screen in the first image can be matched with the screen of the right side computer in the second image (it should have been matched with the left-side computer).
All of the above are my guesses, though I believe they are correct. Good way to confirm these would be to visualize matchings. Your image should not have a lot of repetitive and ambiguous patterns. For example, keyboard keys, small text on screen etc.