import cv2
import numpy as np
def video_demo():
cap = cv2.VideoCapture(0,cv2.CAP_DSHOW)
while(True):
ret,frame = cap.read()
frame = cv2.flip(frame, 1)
cv2.imshow("capture", frame)
cv2.imshow("video", frame)
c = cv2.waitKey(50)
if c == 27:
break
video_demo()
cv2.destroyAllWindows()
runfile('C:/Users/Administrator/.spyder-py3/temp.py', wdir='C:/Users/Administrator/.spyder-py3')
Traceback (most recent call last):
File "C:\Users\Administrator\.spyder-py3\temp.py", line 10, in <module>
ret,frame = cap.read()
NameError: name 'cap' is not defined