4daJKong
4daJKong

Reputation: 2045

`Module 'cv2' has no 'cvtColor' member pylint(no-member)` on VS Code

I have installed opencv by windows DOS, and it can be sucessfully imported in vscode, but when I use this method: cvtColor it shows Module 'cv2' has no 'cvtColor' memberpylint(no-member)

and when I run this code:

cv2_rgb = cv2.cvtColor(val_xyz, cv2.COLOR_XYZ2RGB)

val_xyz = [ 15.4999257 20.91432805 8.15938343]

it shows:

Exception has occurred: error
OpenCV(4.2.0) c:\projects\opencv-python\opencv\modules\imgproc\src\color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function '__cdecl cv::impl::`anonymous-namespace'::CvtHelper<struct cv::impl::`anonymous namespace'::Set<3,-1,-1>,struct cv::impl::A0x2c98332e::Set<3,4,-1>,struct cv::impl::A0x2c98332e::Set<0,2,5>,2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int)'
> Invalid number of channels in input image:
>     'VScn::contains(scn)'
> where
>     'scn' is 1
  File "C:\dataset\opencv_hello.py", line 33, in <module>
    cv2_lab = cv2.cvtColor(val_xyz, cv2.COLOR_XYZ2RGB)

Upvotes: 0

Views: 3216

Answers (1)

Brett Cannon
Brett Cannon

Reputation: 16010

It's a shortcoming of Pylint. You can either:

  • Disable the warning on the specific line (# pylint: disable=no-member)
  • Disable this warning for cv2 via a .pylintrc file:
    [TYPECHECK]
    ignored-modules=cv2
  • Disable the warning globally via a .pylintrc file:
    [MESSAGES CONTROL]
    disable=no-member
  • Disable Pylint itself

Upvotes: 7

Related Questions