1、算法介绍
ORB(Oriented FAST and Rotated BRIEF)是一种快速特征点提取和描述的算法。ORB算法分为两部分,分别是特征点提取和特征点描述。
特征提取是由FAST(Features from Accelerated Segment Test)算法发展来的
特征点描述是根据BRIEF(Binary Robust IndependentElementary Features)特征描述算法改进的。
ORB特征是将FAST特征点的检测方法与BRIEF特征描述子结合起来,并在它们原来的基础上做了改进与优化。据说,ORB算法的速度是sift的100倍,是surf的10倍。
https://blog.csdn.net/kevin_cc98/article/details/75123316
https://blog.csdn.net/qq_40213457/article/details/80848952
代码:
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()