Hello,
I have installed OpenCV and VS Code correctly –> and am running VS Code out of the proper environment from my Anaconda Navigator.
HOWEVER, once inside Visual Studio–> I still have an issue with the first two import commands– 1) import numpy as np and 2) import cv2– with the knock on effect rendering errors to the ensuing code.
When I try to run the ensuing code as follows::
- img = cv2.imread(‘capstone_coins.png’,cv2.IMREAD_GRAYSCALE)
- original_image = cv2.imread(‘capstone_coins.png’,1)
- img = cv2.GaussianBlur(img, (5,5), 0)
- cv2.imshow(‘Detected Coins’, img)
I Receive the following errors :
- {“Module ‘cv2’ has no ‘imread’ member“,
“source”: “pylint”,
“startLineNumber”: 4,
“startColumn”: 7, - Module ‘cv2’ has no ‘IMREAD_GRAYSCALE’ member“,
“source”: “pylint”,
“startLineNumber”: 4,
“startColumn”: 39,
“endLineNumber”: 4,
“endColumn”: 39 - Module ‘cv2’ has no ‘GaussianBlur’ member“,
“source”: “pylint”,
“startLineNumber”: 6,
“startColumn”: 7,
“endLineNumber”: 6,
“endColumn”: 7 - “message”: “Module ‘cv2’ has no ‘imshow’ member”,
“source”: “pylint”,
“startLineNumber”: 7,
“startColumn”: 1,
“endLineNumber”: 7,
“endColumn”: 1
In summary:
- When I run the “import numpy as np” and ” import cv2″ lines– everything seems fine as in no errors in the: i) terminal or 2) “problems” tabs (see screen shot 1 attached)
- BUT, I run the ensuing code I get an cv2 has no “imread’ member error or imread_GRAYSCALE member ( see attached screenshot error_2)
- Then as I run further code Ireceive an error for both “cv2 has no gaussianblur” member and cv2 has no “imshow” member ( see attached screenshot error_3)
–> This leads me to believe that cv2 was not properly imported from the start??
Any help would be greatly appreciated… I have been stuck on this issue for many days and have tried multiple debugging methods and alternatives– to no avail!!
Thanks,
Matt
Partial update,
After attempting the following troubleshoot method:
- On VScode: CTRL + Shift + P
- Choose “Preferences: Open Settings (JSON)”
- Add this line into JSON file: “python.linting.pylintArgs”: [“–generate-members”]
I was able to create the two variables img and original_image successfully.
However, when trying to run “img” as a blurred grayscale image with: img = cv2.GaussianBlur(img, (5,5), 0) –> I get the following Traceback error:
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\core\src\matrix.cpp:757: error: (-215:Assertion failed) dims <= 2 && step[0] > 0 in function ‘cv::Mat::locateROI’
Making progress but still troubleshooting. Part of enjoying the process and not the destination!
Hello my friend,
Have you got any solution for the problem? I’m stuck on the same issue.
cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-2b5g8ysb\opencv\modules\imgproc\src\smooth.dispatch.cpp:620: error: (-215:Assertion failed)
!_src.empty() in function ‘cv::GaussianBlur’
Thanks for the attention