1. 程式人生 > >影象處理之特徵提取-ORP特徵匹配

影象處理之特徵提取-ORP特徵匹配

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倍。

程式碼:

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()