今天在mac上用python opencv4的时候出现了下面的错误:

module 'cv2.cv2' has no attribute 'xfeatures2d'

解决方法

pip install opencv-python==3.4.2.16
pip install opencv-contrib-python==3.4.2.16

参考文献

[1]. sift = cv2.xfeatures2d.SIFT_create() not working even though have contrib installed. ​​https://stackoverflow.com/questions/52305578/sift-cv2-xfeatures2d-sift-create-not-working-even-though-have-contrib-instal​

[2]. opencv python SIFT(尺度不变特征变换). ​