3.X以后OpenCv只包含部分内容,需要神经网络或者其他的函数需要导入opencv_contrib
解决方法:

pip install opencv-contrib-python

注意:
如果已经安装OpenCv2,则需要先卸载pip uninstall opencv-python再安装
执行命令:
pip install opencv-contrib-python

会出现 C:\projects\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 ‘cv::xfeatures2d::SIFT::create’

建议安装3.3.0.10版本的contrib,更高版本的contrib里面专利保护了SIFT和SURF. 请执行
pip install opencv-contrib-python==3.3.0.10