ORB特征匹配(python)

输入的两个图

这里写图片描述

这里写图片描述

输出图片

这里写图片描述

虽然感觉有点不太准。

代码

import cv2
from matplotlib import pyplot as plt

img1 = cv2.imread('6.jpg', cv2.IMREAD_GRAYSCALE)
img2 = cv2.imread('7.jpg', cv2.IMREAD_GRAYSCALE)
orb = cv2.ORB_create()
kp1, des1 = orb.detectAndCompute(img1, None)
kp2, des2 = orb.detectAndCompute(img2, None)
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = bf.match(des1, des2)
matches = sorted(matches, key=lambda x: x.distance)
img3 = cv2.drawMatches(img1, kp1, img2, kp2, matches[:80], img2, flags=2)

plt.imshow(img3), plt.show()

猜你喜欢

转载自blog.csdn.net/a19990412/article/details/81208468