最近做视频稳像需要用到surf提取特征,就需要用到opencv-contrib-python包中的cv2.xfeatures2d接口,不论安装opencv-python。还是opencv-contrib-python,都报如下错误:
cv2.error: OpenCV(4.1.0) /io/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 'create'
看到有同学说opencv-contrib-python 3.4以上的版本都不支持此接口了,折腾半天后,解决方案如下:
1. 卸载已有安装opencv-python:
pip uninstall opencv-python
2. 安装opencv-contrib-python 3.2版本以下:
pip install opencv-contrib-python==3.4.2