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

问题描述

我一直在用 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])

这给出了我无法理解的以下错误。

cv2.error: OpenCV(4.1.2) /io/opencv/modules/imgproc/include/opencv2/imgproc/detail/gcgraph.hpp:121: error: (-215:Assertion failed) w>=0 && revw>=0 在函数 'addEdges'

这是我可以设置的最简单的例子,请帮助我做错了什么。

按要求,我正在添加输入图像

n3/0.jpg

n3/0.jpg

n3/5.jpg

n3/5.jpg

UPADTE

通过使用另一种方法,我达到了预期的效果,但我仍然想使用内置函数。请帮忙

resultant image after using the masks

resultant image after using the masks

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...