python opencv 拼接失败_OpenCV Python不精确图像拼接

我使用python3.5和opencv来缝合图像。图像的尺寸是1920 X 1080。到目前为止,我已经使用了SIFT和ORB,任何缝合的迹象都只能在SIFT和{}中看到,我要么得到训练图像,要么得到一个非常扭曲的图像。。在

实际的图像拼接是根据这本书OpenCV with Python by Example实现的。这似乎是使用python和opencv拼接图像的标准方法,正如在这里和网上看到的各种帖子一样。在

这是缝合图像的代码def warpImages(train_img , query_img , H):

# This function waprs query image to train image

t_row , t_col = train_img.shape[: 2]

q_row , q_col = query_img.shape[: 2]

list_pts1 = np.float32([[0 , 0] , [0 , t_row] , [t_col , t_row] , [t_col , 0]]).reshape(-1 , 1 , 2)

temp_points = np.float32([[0 , 0] , [0 , q_row] , [q_col , q_row] , [q_col , 0]]).reshape(-1 , 1 , 2)

list_pts2 = cv2.perspectiveTransform(temp_points , H)

list_pts = np.concatenate((list_pts1 , list_pts2) , axis = 0)

[x_min , y_min] = np.int32(list_pts.min(axis = 0).ravel() - 0.5)

[x_max , y_max] = np.int32(list_pts.max(axis = 0).ravel() + 0.5)

print(x_max , x_min)

print(y_max , y_min)

translation_dist = [-x_min , -y_min]

H_translation = np.array([[1 , 0 , translation_dist[0]] , [0 , 1 , translation_dist[1]] , [0 , 0 , 1]])

output_img = cv2.warpPerspective(query_img , H_translation.dot(H) , (x_max - x_min , y_max - y_min))

output_img[translation_dist[1] : t_row + translation_dist[1] , translation_dist[0] : translation_dist[0] + t_col ] = train_img

return output_img

这是为了找到Homography Matrix and Features。在

^{pr2}$

从上面的代码中可以看出,我已经注释了ORB和{},因为结果图像没有缝合。'SIFT'给了我一个不太准确的结果,也占用了时间来处理,这是可以理解的。在

以下是使用的图像:

查询图像:

xspNr.jpg

列车图像Ms79L.jpg

使用SIFT的结果图像u1MMN.jpg

使用结果

1OYM7.jpg

可以看出ORB给出了一个错误的结果,在SIFT中,它看起来像是一个重复的模式。ORB的速度更快。我在这里引用了以下帖子:

^{{a8}这里的{a8}不适合拼接}图像。在

我是新的图像缝合,真的希望一些关于如何处理和处理这一点的建议。在

更新

添加匹配特征图R039f.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值