SURF not exist in opencv-contrib-python

SIFT and SURF are examples of algorithms that OpenCV calls “non-free” modules. These algorithms are patented by their respective creators, and they are free to use in academic and research settings and installed with this command:

pip install opencv-contrib-python

However after installation, using SURF algorithm cause the error:

OpenCV(3.4.11) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-neg5amx3\opencv_contrib\modules\xfeatures2d\src\surf.cpp:1029: error: 
(-213:The function/feature is not implemented) This algorithm is patented and is excluded in this
configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 

the error exist in version of opencv-contrib-python. this is my code to use SURF

SURF = cv.xfeatures2d.SURF_create()
kp,des = FREAK.compute(img_gray,kp)

Your question seems to be unrelated to PyTorch, so I would recommend to post it in an OpenCV discussion board or their GitHub repository.

Based on the error message I guess you might need to rebuild OpenCV with the mentioned option to enable these patented algorithms as the public version doesn’t seem to ship with it (again I guess also due to licensing issues).

Agree with @ptrblck , you should go to opencv forums. However, if you like pytorch and opencv you can use Kornia re-implementation of sift found in Kornia

1 Like