AttributeError: module 'cv2' has no attribute 'SIFT'

原因:opencv将SIFT等算法整合到xfeatures2d集合里面了。

将siftDetector=cv2.SIFT()

变更后为

siftDetector= cv2.xfeatures2d.SIFT_create()

即可正常使用SIFT算法。

import cv2
import numpy as np

img = cv2.imread('C:/Users/www12/Desktop/Photo/test_1.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

sift = cv2.xfeatures2d.SIFT_create()
kp = sift.detect(gray, None)

img = cv2.drawKeypoints(gray, kp, img)

cv2.imshow('img',cv2.resize(img, (800, 600))) 
cv2.waitKey(0) 
cv2.destroyAllWindows()

你可能感兴趣的:(Opencv,AttributeError:,module,'cv2',has,no)