Using OpenCV in python, I am trying to stitch multiple images that are out of order. I have a functioning stitch method that stitches two images, given which one is on the left and right.
def stitch(self, images, ratio=0.75, reprojThresh=4.0,
showMatches=False):
"""
This function performs image stitching with help of other member functions of Stitcher class.
Args:
images (list) : List of two images ordered left to right
ratio (float) : Ratio for Lowe's Test
reprojThresh (float) : reprojThresh parameter for RANSAC for homography computation
showMatches (bool) : Flag for marking showing matches on input images
"""
(imageL, imageR) = images
#Find key points and features for input images
(kpsR, featuresR) = self.find_kp_features(imageR)
(kpsL, featuresL) = self.find_kp_features(imageL)
# Match features between two input images
M = self.matchKeypoints(kpsR, kpsL, featuresR, featuresL, ratio, reprojThresh)
if M is None:
return None
(matches, H, status) = M
#Perform perspective correction on second image (imageR)
result = cv2.warpPerspective(imageR, H, (imageR.shape[1] + imageL.shape[1], imageR.shape[0]))
#Insert Left image (imageL) in result to obtai stitched image
result[0:imageL.shape[0], 0:imageL.shape[1]] = imageL
if showMatches:
vis = self.drawMatches(imageR, imageL, kpsR, kpsL, matches,
status)
return (result, vis)
return result
source: https://github.com/TejasBob/Panorama/blob/master/image-stitching-report.pdf
I have read through the following paper, but I am still confused on an approach to stitching multiple images together that are in a random order. I have considered using a bundle adjustment algorithm, but am unaware of a possible implementation for this.
My question is what would be the best way to stitch together multiple images that are out of order? Some suitable material or pseudo code of what I can do will also be helpful.