ModuleNotFoundError: No module named 'cv2.ximgproc

Viewed 4312

When I am running the command from cv2.ximgproc import guidedFilter, I am getting an error: ModuleNotFoundError: No module named 'cv2.ximgproc'

I searched the Internet for possible reasons, and I found out that I should run a command pip install opencv--contrib-python on the terminal, which I did. Even after doing that, I am getting the same error.

Please note that I am not very good at programming and technical stuff, so please explain in simple terms. I have a mac, and I am using Anaconda for writing my codes.

2 Answers

You need to uninstall the regular opencv package first.

First uninstall both regular opencv as well as contrib package:

pip uninstall opencv-python
pip uninstall opencv-contrib-python

Then install the contrib package:

pip install opencv-contrib-python

You can refer to this post for more information: Module 'cv2.cv2' has no attribute 'ximgproc'

I have written a python script as follows:

from cv2.ximgproc import guidedFilter
print("hello")

Initially it was giving me the same error : 'ModuleNotFoundError: No module named 'cv2.ximgproc'. But then i ran the command "pip install opencv--contrib-python" and after that it prints "hello" i.e it is detecting the ximgproc module. please check the below screenshot.enter image description here

Check once the installation of opencv--contrib module. There is some problem at that stage.

Related