如何拿到SIFT匹配对的每个点
时间: 2023-07-09 22:32:45 浏览: 44
要拿到SIFT匹配对的每个点,首先需要使用SIFT算法对两张图像进行特征点提取和匹配。然后,可以通过以下步骤来获取每个匹配点的坐标:
1. 遍历匹配对的列表,获取每个匹配对的索引。
2. 使用索引获取第一张图像和第二张图像中的对应特征点的坐标。
3. 将两个坐标作为一个匹配对返回。
在Python中,可以使用OpenCV库来实现SIFT算法的特征点提取和匹配,并且可以通过以下代码获取每个匹配点的坐标:
```
import cv2
# 读取两张图像
img1 = cv2.imread('image1.jpg')
img2 = cv2.imread('image2.jpg')
# 创建SIFT对象
sift = cv2.xfeatures2d.SIFT_create()
# 提取特征点和特征描述符
kp1, des1 = sift.detectAndCompute(img1, None)
kp2, des2 = sift.detectAndCompute(img2, None)
# 创建FLANN匹配器
matcher = cv2.FlannBasedMatcher()
# 进行特征点匹配
matches = matcher.match(des1, des2)
# 获取匹配点的坐标
points1 = []
points2 = []
for match in matches:
points1.append(kp1[match.queryIdx].pt)
points2.append(kp2[match.trainIdx].pt)
# 输出匹配点的坐标
print(points1)
print(points2)
```
这样就可以获取到SIFT匹配对的每个点的坐标了。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)