opencv3.x 中部分函数有改变:
1. SIFT:可以采用help(cv2.xfeatures2d)查询
2.drawKeypoints: 同样采用help()方法查询
opencv3 版本sift,surf 及其他不稳定的算法函数都放在opencv3.x的contrib版里。该模块下载地址 https://www.lfd.uci.edu/~gohlke/pythonlibs/
#Python 3.6.2 |Anaconda import cv2 import numpy as np #read image img = cv2.imread(r‘test.jpg‘,cv2.IMREAD_COLOR) gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) cv2.imshow(‘origin‘,img); #SIFT detector = cv2.xfeatures2d.SIFT_create() keypoints = detector.detect(gray,None) cv2.drawKeypoints(gray,keypoints,img) #img = cv2.drawKeypoints(gray,keypoints,flags = cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS) cv2.imshow(‘test‘,img); cv2.waitKey(0) cv2.destroyAllWindows()