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()
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