Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

python - AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d' [Opencv 3.4.3]

I have opencv 3.4.3 installed (using pip3 install opencv-python and pip3 install opencv-python-contrib)

When I run a code containing this line:
sift = cv2.xfeatures2d.SIFT_create()
I got this error:

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

Is xfeatures2d function not anymore supported by opencv 3.4.3?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The error message you have is related to the fact that the module xfeatures2d does not exist. It is not directly related to SIFT algorithm nor any algorithm in xfeatures2d (all will send that error). I suggest you to either reinstall opencv-contrib-python(pip install opencv-contrib-python) or if you are using anaconda or equivalent to re-install the two opencv package from another source repository. A last option consist to compile the full OpenCV ("regular" + contrib) by yourself if you are comfortable with it.

Hope it helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...