报错AttributeError: module ‘cv2’ has no attribute ‘ximgproc’
首先查看是否安装opencv-contrib-python
pip list | grep opencv
显示
opencv-contrib-python 4.4.0.46
opencv-python 4.8.1.78
opencv-python-headless 4.7.0.72
说明本机上已经成功安装 opencv-contrib-python, opencv-python ,opencv-python-headless模块,但是为什么还会报错module ‘cv2’ has no attribute 'ximgproc’呢?
由于版本不一致的问题导致的。
将opencv-contrib-python升级为 opencv-python 一致的版本即可解决
pip install opencv-contrib-python==4.8.1.78
解决后,再测试查看各模块版本为:
pip list | grep opencv
显示
opencv-contrib-python 4.8.1.78
opencv-python 4.8.1.78
opencv-python-headless 4.7.0.72