Last answered:

14 May 2021

Posted on:

09 Jun 2020


Capstone Project Computer Vision coin classification– Starting to work with Visual Studio


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::

  1. img = cv2.imread('capstone_coins.png',cv2.IMREAD_GRAYSCALE)
  2. original_image = cv2.imread('capstone_coins.png',1)
  3. img = cv2.GaussianBlur(img, (5,5), 0)
  4. cv2.imshow('Detected Coins', img)

I Receive the following errors :

  1. {"Module 'cv2' has no 'imread' member",
    "source": "pylint",
    "startLineNumber": 4,
    "startColumn": 7,
  2. Module 'cv2' has no 'IMREAD_GRAYSCALE' member",
    "source": "pylint",
    "startLineNumber": 4,
    "startColumn": 39,
    "endLineNumber": 4,
    "endColumn": 39
  3. Module 'cv2' has no 'GaussianBlur' member",
    "source": "pylint",
    "startLineNumber": 6,
    "startColumn": 7,
    "endLineNumber": 6,
    "endColumn": 7
  4. "message": "Module 'cv2' has no 'imshow' member",
    "source": "pylint",
    "startLineNumber": 7,
    "startColumn": 1,
    "endLineNumber": 7,
    "endColumn": 1

In summary:

  1. 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)
  2. BUT, I run the ensuing code I get an cv2 has no "imread' member error or imread_GRAYSCALE member ( see attached screenshot error_2)
  3. 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!!



3 answers ( 0 marked as helpful)
Posted on:

12 Jun 2020

Partial update, After attempting the following troubleshoot method:
  1. On VScode: CTRL + Shift + P
  2. Choose "Preferences: Open Settings (JSON)"
  3. 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!  
Posted on:

22 Sept 2020

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
Posted on:

14 May 2021


Hi, I ran into the same issue. I still haven't found anyone with a solution on making the code run smoothly like Giles did. Anyone have an update or a solution?

Submit an answer