AttributeError: 'module' object has no attribute 'xfeatures2d' [Python/OpenCV 2.4]

前端 未结 10 1154
我寻月下人不归
我寻月下人不归 2020-12-01 15:39

This line:

sift = cv2.xfeatures2d.SIFT_create()

return error:

Traceback (most recent call last):
  File \"C:/Python27/openC         


        
相关标签:
10条回答
  • 2020-12-01 16:12

    SIFT is a patented algorithm, hence not available in each open-cv version. What you can do is install opencv and its contrib part simultaneously, i.e,

    pip install opencv-python==3.3.0.10 opencv-contrib-python==3.3.0.10
    

    SIFT worked fine for me on above versions of opencv.

    0 讨论(0)
  • 2020-12-01 16:12

    This error may also occur in OpenCV 3+ as it is caused by mismatched versions of OpenCV and OpenCV-Contrib package.

    I had OpenCV version 3.4.1 and OpenCV-Contrib version 3.4.0. I tried the following with OpenCV-Contrib:

    Uninstall OpenCV-Contrib package:

    $ pip uninstall opencv-contrib-python
    

    Then install the same again:

    $ pip install opencv-contrib-python
    

    The pip automatically fetches and installs the latest compatible version.

    0 讨论(0)
  • 2020-12-01 16:13

    I got this error and all I did was to uninstall opencv packages and install them in the following order.

    STEPS

    open Anaconda Prompt by running as administrator and type the following commands.

    $ pip uninstall opencv-python
    
    $ pip uninstall opencv-contrib-python
    

    Then type the following commands

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

    This solved my problem. Hope this solves yours.!!

    0 讨论(0)
  • 2020-12-01 16:13

    You can use this instead:

    sift=cv2.SIFT()
    
    0 讨论(0)
  • 2020-12-01 16:14

    The problem is with your version of OpenCV. You say you're on version 2.4.11 but this version of OpenCV doesn't have this method available to it.

    You can check the documentation. It has features2d

    Whereas OpenCV 3.0 does.

    0 讨论(0)
  • 2020-12-01 16:20

    I used to have similar problem as @srihegde said you can try to uninstall opencv-contrib-python package and reinstall again. You can also try to uninstall opencv-python package if you have one, since it might mess with the packages too.

    This helped for me.

    Uninstall:

    pip3 uninstall opencv-contrib-python
    pip3 uninstall opencv-python
    

    And then install:

    pip3 install opencv-contrib-python
    pip3 install opencv-python
    
    0 讨论(0)
提交回复
热议问题