python ransac_如何在Python OpenCV中应用RANSAC

本文展示了如何在Python中结合OpenCV利用RANSAC算法找到最佳的特征匹配点。通过SIFT算法获取特征匹配后,使用RANSAC计算单应矩阵,实现图像的透视变换。
摘要由CSDN通过智能技术生成

有人能告诉我如何应用RANSAC来找到最好的4个特征匹配点及其对应的(x,y)坐标,以便我可以在我的单应码中使用它们吗?

特征匹配点由SIFT获得,代码如下:import numpy as np

import cv2

from matplotlib import pyplot as plt

def drawMatches(img1, kp1, img2, kp2, matches):

rows1 = img1.shape[0]

cols1 = img1.shape[1]

rows2 = img2.shape[0]

cols2 = img2.shape[1]

out = np.zeros((max([rows1,rows2]),cols1+cols2,3), dtype='uint8')

# Place the first image to the left

out[:rows1,:cols1] = np.dstack([img1, img1, img1])

# Place the next image to the right of it

out[:rows2,cols1:] = np.dstack([img2, img2, img2])

# For each pair of points we have between both images

# draw circles, then connect a line between them

for mat in matches:

# Get the matching keypoints for each of the images

img1_idx = mat.qu

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值