2015-11-12 47 views

回答

4

您可以嘗試ORB(Oriented FAST and Rotated BRIEF)作爲SURF在開放式CV中的替代方案。它幾乎可以作爲SURF好過篩,它是免費的不像 SIFT SURF 其中專利並且不能用於商業用途。
可以OpenCV的-Python文檔 here

在這裏,更多的瞭解這對您的放心

import cv2 
from matplotlib import pyplot as plt 

img1 = cv2.imread('text.png',cv2.COLOR_BGR2GRAY) # queryImage 
img2 = cv2.imread('original.png',cv2.COLOR_BGR2GRAY) # trainImage 
# Initiate SIFT detector 
orb = cv2.ORB_create() 

# find the keypoints and descriptors with SIFT 
kp1, des1 = orb.detectAndCompute(img1,None) 
kp2, des2 = orb.detectAndCompute(img2,None) 
# create BFMatcher object 
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True) 
# Match descriptors. 
matches = bf.match(des1,des2) 

# Sort them in the order of their distance. 
matches = sorted(matches, key = lambda x:x.distance) 
# Draw first 10 matches. 
img3 = cv2.drawMatches(img1,kp1,img2,kp2,matches[:10],None, flags=2) 

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

它可以在opencv 2.7或2.4下運行嗎?因爲我得到了ORB的相同錯誤。 – pallavi

+0

我用它打開cv 3.0 – Ahmed

+0

@ pallavi請檢查編輯的答案。 – Ahmed

0

示例代碼起初

pip install opencv-contrib-python 

,然後使用此技巧創建過篩對象

sift = cv2.xfeatures2d.SIFT_create() 
+0

我不知道那件事......會測試一下! – user1767754