A similar question to mine exists, however it does not answer my question.
Here is what I am working with:
Python v. 3.6.2
opencv 1.0.1
PyCharm Community Edition 2017 .2.2
macOS Sierra Version 10.12.6
I'm trying to use imread for image processing. I've looked at the documentation and I am using the function correctly. Here is the test code that comes with the opencv library:
import opencv img = cv.imread('background.png') if img is None: print("Image not loaded!") else: print("Image is loaded!") I can see my python files and and modules in the project explorer. When I run the code, I get the following error:
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/lmc/Desktop/pywerk/opencvpractice Traceback (most recent call last): File "/Users/lmc/Desktop/pywerk/opencvpractice", line 4, in img = cv.imread('background.png') AttributeError: module 'opencv' has no attribute 'imread'
I've tried everything from reinstalling python and the opencv module to switching python versions to 2.7 (and using the respective opencv module) and I get the same error.
Is there some sort of system configuration I could be missing? Any help would be much appreciated.
cv2module? Thecv2module uses anumpybackend for image storing so it's far superior for working with the data. Anyways, the answer below should fix you up; you're importingopencvyet using the namespacecvwhich you haven't defined.