Some functions in opencv3.1 have changed:
1. SIFT: You can use Help (cv2.xfeatures2d) query
2.drawKeypoints: Also using the Help () method query,
Import Cv2
Import NumPy as NP
#read image
img = cv2.imread (' test.jpg ', Cv2. Imread_color)
Gray = Cv2.cvtcolor (img, Cv2. Color_bgr2gray)
Cv2.imshow (' Origin ', img)
#SIFT
sift= Cv2.xfeatures2d.SIFT_create ()
Keypoints = Sift.detect (Gray, None)
#kp, des = Sift.detectandcompute (Gray,none) #des是描述子, for match, should use DES, BF = cv2. Bfmatcher (); smatches = Bf.knnmatch (Des1,des2, k=2
Cv2.drawkeypoints (Gray, Keypoints, IMG)
Cv2.imshow (' Testsift ', IMG)
Cv2.waitkey (0)
Cv2.destroyallwindows ()
# # #notes: Narray to image data for sift computing:
>>> Img_array=np.zeros ([10,10,3])
>>> Img_array[:,:,0]=np.ones ([10,10]) *255
>>> Img_array[:,:,1]=np.ones ([10,10]) *255
>>> Img_array[:,:,2]=np.ones ([10,10]) *0
>>> img_uint8=np.uint8 (Img_array) #img_gray =cv2.cvtcolor (Img_array, Cv2. Color_bgr2gray)
>>> Sift=cv2.xfeatures2d.sift_create ()
>>> KP, Des=sift.detectandcompute (img_uint8, None)