OpenCV:使用GraphCutSeamFinder以最佳接缝拼接两幅图像

r3i60tvu  于 2022-11-15  发布在  其他
关注(0)|答案(2)|浏览(352)

我一直在做一个自动全景缝合器在python和现在卡在接缝寻找步骤。以下是我的代码在结构中,我从opencv文件理解。

im1 = cv2.imread('n3/0.jpg')
im2 = cv2.imread('n3/5.jpg')

c1 = [0,0]
c2 = [5,130] #calculated using ORB feature matching

mask1 = np.full(im1.shape[:2], 255)
mask2 = np.full(im2.shape[:2], 255)

finder = cv2.detail_GraphCutSeamFinder("COST_COLOR_GRAD")
finder.find([im1, im2], [c1, c2], [mask1, mask2])

这给出了以下错误,我无法理解。
请输入以下代码:错误:(-215:Assert失败)函数'addEdges'中w〉=0 && revw〉=0
这是我能建立的最简单的例子,请帮助我做错了什么。
根据要求,我正在添加输入图像
n3/0.jpg

n3/5.jpg

更新

通过使用另一种方法,我已经达到了预期的效果,但我仍然想使用内置函数。请帮助
resultant image after using the masks

vm0i2vca

vm0i2vca1#

mask1 = np.full(bl.shape[:2], 255, dtype=np.uint8)

mask2 = np.full(br.shape[:2], 255, dtype=np.uint8)

这对我很有效。我使用了https://github.com/lukasalexanderweber/stitching。发现类型是np.uint8。如果删除' dtype=np.uint8 ',掩码将不会更新。

4ioopgfo

4ioopgfo2#

图形切割接缝查找器的Python绑定目前已损坏。请监控this PR并进行可能的修复。我希望它能很快被合并。

相关问题