1import numpy as np
2import cv2
3cap = cv2.VideoCapture('videos/wa.avi')
4while(cap.isOpened()):
5 ret, frame = cap.read()
6 gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
7 cv2.imshow('frame',gray)
8 if cv2.waitKey(1) & 0xFF == ord('q'):
9 break
10
11cap.release()
12cv2.destroyAllWindows()
1import cv2
2cap = cv2.VideoCapture()
3# The device number might be 0 or 1 depending on the device and the webcam
4cap.open(0, cv2.CAP_DSHOW)
5while(True):
6 ret, frame = cap.read()
7 cv2.imshow('frame', frame)
8 if cv2.waitKey(1) & 0xFF == ord('q'):
9 break
10cap.release()
11cv2.destroyAllWindows()