Adding modules from opencv_contrib to OpenCV

后端 未结 4 2044
闹比i
闹比i 2020-12-30 05:32

I\'m trying to add the xfeatures2d module from opencv_contrib to an existing OpenCV/Python project.

I\'ve downloaded the latest version of

4条回答
  •  别那么骄傲
    2020-12-30 06:23

    I encountered this same issue. I'm using python 2.7.6 and OpenCv 3.0 with the additional non-free modules. I do have xfeatures2d present in available modules and can import it, however it was as though xfeatures2d didn't contain SIFT or SURF. No matter how I called them it was the same Error:

    "AttributeError: 'module' object has no attribute 'SIFT'

    I tried the different name spaces suggested, and only recently noticed this detail and GOT IT WORKING!

    $ python

    >>>import cv2

    >>>help(cv2.xfeatures2d)

    You'll notice that it replies that it is now referred to as...

    FUNCTIONS

    SIFT_create(...)
    

    and

    SURF_create(...)
    

    So very simply - the namespace is NOT "cv2.SIFT()" or "cv2.xfeatures2d.SIFT" but rather

    cv2.xfeatures2d.SIFT_create()

    Please give it a shot!

提交回复
热议问题