When practicing the
sift operator, I found this problem:
AttributeError: 'module' object has no attribute 'xfeatures2d'
OpenCV version problem, because the sift operator is patented, the original OpenCV cannot include this function, and it can only be included in the extension package `opencv-contrib-python`.
In two versions
1）If the version of opencv-python is
pip install opencv-contrib-python==126.96.36.199
sift = cv2.xfeatures2d.SIFT_create() kp = sift.detect(gray_img, None) img = cv2.drawKeypoints(gray_img, kp, img) plt.imshow(img)
2) If the version of opencv-python is
pip install opencv-contrib-python==188.8.131.52
sift = cv2.SIFT_create() kp = sift.detect(gray_img, None) img = cv2.drawKeypoints(gray_img, kp, img) plt.imshow(img)