I am using the following line in my program
img = cv2.resize(img, dsize=(299, 299), interpolation=cv2.INTER_LINEAR)
It is giving the following error
AttributeError: module 'cv2' has no attribute 'resize'
The type of image img
is <class 'imageio.core.util.Array'>
I checked the official documentation of OpenCV and it contains the attribute resize.
Where am I going wrong?
CodePudding user response:
The issue occurred due to the erroneous installation of OpenCV.
Although the system is behaving as OpenCV was properly installed. It wasn't installed properly.
Uninstalling and installing OpenCV again solved the issue.
pip uninstall opencv-python
and then
pip install opencv-python
CodePudding user response:
Maybe your cv2 import is not correct. In a Python console, try
import cv2
help(cv2.resize)
In case it does not show the description of the resize method, the import does not work properly. Your could also check help(cv2)
which gives a long list of all methods and attributes contained in the module.
Are you working within a virtual environment that needs activation first?