AttributeError: module ‘cv2’ has no attribute ‘saliency’
problem analysis
If cv2 has been successfully installed and import cv2 is successful (as shown in the yellow box in the figure below), the following error will be reported when running:
AttributeError: module 'cv2' has no attribute 'saliency'
This error is usually caused by the installed version of OpenCV not including the saliency module. The saliency module is an extension module of OpenCV for saliency detection
Solution
1. Make sure you install the version of OpenCV that includes the saliency module. You can check the OpenCV version and available modules by running:
import cv2
print(cv2.__version__)
print(dir(cv2))
2. Make sure the saliency module is included in the output. If you installed the OpenCV version installed through pip or conda, and it does not include the saliency module, you can try the methods in 3 and 4 to reinstall OpenCV, and make sure to choose a version that includes the saliency module.
5. If the above methods still cannot solve the problem, it may be because your OpenCV version does not contain the saliency module. pySaliencyMap can be installed using either of the following two commands ( 平替).