Ask Your Question

Revision history [back]

Hi I'm using this code in pycharm and I have this error.please help me

image description

click to hide/show revision 2
retagged

updated 2019-09-02 13:47:48 -0600

berak gravatar image

Hi I'm using this code in pycharm and I have this error.please help me

image description

Hi I'm using this code in pycharm and I have this error.please help me

image descriptionimport numpy as np import cv2

cap=cv2.VideoCapture(0) while(True): ret,frame=cap.read() gray = cv2.cvtColor(frame ,cv2.COLOR_BGR2GRAY) cv2.imshow('frame',gray) if cv2.waitKey(1) : break cap.release() cv2.destroyAllWindows()

and the error is: OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cv::cvtColor, file C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\imgproc\src\color.cpp, line 9748 Traceback (most recent call last): File "D:/python/examples_with_pyCharm/untitled2/Lesson3_VIDEO.py", line 7, in <module> gray = cv2.cvtColor(frame ,cv2.COLOR_BGR2GRAY) cv2.error: C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\imgproc\src\color.cpp:9748: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor

click to hide/show revision 4
None

updated 2019-09-02 14:59:39 -0600

berak gravatar image

Hi I'm using this code in pycharm and I have this error.please help me

import numpy as np import cv2

cap=cv2.VideoCapture(0)
while(True):
    ret,frame=cap.read()
    gray = cv2.cvtColor(frame ,cv2.COLOR_BGR2GRAY)
    cv2.imshow('frame',gray)
    if cv2.waitKey(1) :
        break
cap.release()
cv2.destroyAllWindows()

cv2.destroyAllWindows()

and the error is: is:

OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cv::cvtColor, file C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\imgproc\src\color.cpp, line 9748
Traceback (most recent call last):
  File "D:/python/examples_with_pyCharm/untitled2/Lesson3_VIDEO.py", line 7, in <module>
    gray = cv2.cvtColor(frame ,cv2.COLOR_BGR2GRAY)
cv2.error: C:\build\master_winpack-bindings-win64-vc14-static\opencv\modules\imgproc\src\color.cpp:9748: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor

cv::cvtColor