1import cv2
2
3cap = cv2.VideoCapture(0)
4
5while True:
6 ret, frame = cap.read()
7
8 cv2.imshow('webcam feed' , frame)
9 if cv2.waitKey(1) & 0xFF == ord(' '):
10 break
11
12cap.release()
13cv2.destroyAllWindows()
14
15#by using the spacebar you will be able to finish the process of video capturing
16#in opencv and the window will close
1import cv2
2
3cap = cv2.VideoCapture(0)
4
5while True:
6 success, img = cap.read()
7 cv2.imshow("Webcam", img)
8 if cv2.waitKey(1) == ord('q'):
9 break