python - 在openCV warpPerspective中,如何转换左侧图像并将其缝合到右侧图像?

标签 python opencv image-processing computer-vision image-stitching

我正在尝试通过执行SIFT-> KNN-> warpPerspective使用OpenCV进行图像拼接。关于如何使右边的图像变形以拼接到左边的目标,有很多资源。我试过计算单应矩阵以使左图像扭曲到右缝,这似乎可行。问题是,我无法将图像与cv2.warpPerspective拼接在一起,因为它似乎将图像放置在右侧图像变形的地方。

我的代码基本上是:

result = cv2.warpPerspective(left, H, (left.shape[1] + right.shape[1], left.shape[0])
result[0:right.shape[0], result.shape[1]-right[1]:] = right

但这会导致图像偏移向右偏移。如何正确拼接图像?

最佳答案

首先,您应该调整图像大小并将其放置在较大的图像中outer_x= image_x*5outer_y= image_y*3

outer_x= image_x*5
outer_y= image_y*3
result = cv.warpPerspective(left_image, H, (outer_x, outer_y))
result[:, x_img * 2 : x_img*3] = right_image[j][:, x_img * 2 : x_img*3]

关于python - 在openCV warpPerspective中,如何转换左侧图像并将其缝合到右侧图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57999284/

相关文章:

python - fileinput.Fileinput .read() 整个文件的函数

java - 通过大津法的 "slower version"计算阈值

c++ - 如何在opencv cpp中获取霍夫变换矩阵,霍夫变换的theta和rho值

python - 如何使用opencv对齐多个相机图像

c++ - OpenCL copyto() 消耗更多时间

image-processing - ImageMagick 缩略图 Windows 上的批处理

python - 遵循教程后的 m2m django 实现

python 如何在不重新下载的情况下将 tika 与现有的 jar 文件一起使用

python - 使用 Anaconda python 代替默认的 mac python

python - 如何将openCV中的imshow()和moveWindow()与python结合起来?