在python中使用OpenCV,我试图缝合多个无序的图像。我有一个功能性的缝合方法,缝合两个图像,给定哪一个在左边和右边。在
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
来源:https://github.com/TejasBob/Panorama/blob/master/image-stitching-report.pdf
我已经通读了下面的paper,但是我仍然对如何将多个图像以随机顺序缝合在一起的方法感到困惑。我已经考虑过使用捆绑调整算法,但不知道可能实现这一点。在
我的问题是,什么是最好的方法缝合在一起的多个图像无序?一些合适的材料或我能做的伪代码也会有帮助。在
对于随机顺序提供的多个图像缝合,您可以尝试以下操作:
1)在一张图像中查找特征
2)尝试匹配所有图像中的这些特征
3)与初始图像最大匹配的图像选择并执行缝合
4)现在您有了一个新的缝合图像,您可以在其中添加特征,并在其他帧中再次匹配它们,依此类推。在
这会很费时,但可以考虑一下这个方向。在
相关问题 更多 >
编程相关推荐