我有一个Python / OpenCV项目,正在尝试使用来自opencv-contrib的xfeatures2d模块。我正在使用Mac,而我的IDE是PyCharm。我已经通过“首选项”>“项目解释器”安装了软件包opencv-contrib-python和opencv-python。
但是,当我尝试运行下面的代码时,出现以下错误:
import cv2
import numpy as np
img = cv2.imread("NotreDame.jpg", 0)
sift = cv2.xfeatures2d.SIFT_create()
line 6, in <module>
sift = cv2.xfeatures2d.SIFT_create()
cv2.error: OpenCV(4.1.0) /Users/travis/build/skvark/opencv-python/opencv_contrib/modules/xfeatures2d/src/sift.cpp:1207: 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 'create'
我已经使用以下方法在计算机上安装了opencv和opencv-contrib:
$ pip install opencv-python==3.4.2.17
$ pip install opencv-contrib-python==3.4.2.17
我不确定如何解决此错误。任何见解都会受到赞赏。