報錯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