Skip to content

Commit 736f55c

Browse files
authored
Create python webcam.py
1 parent faeb10b commit 736f55c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

python webcam.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import cv2
2+
3+
# id of the video capturing device to open. To open default camera using default backend just pass 0.
4+
capture = cv2.VideoCapture(0)
5+
6+
while True:
7+
_, frame = capture.read()
8+
# We give the Window a name of "Capture from Webcam", and we also give it the frame which is an numpy object.
9+
cv2.imshow("Capture from Webcam", frame)
10+
# We know that the ASCII code for the Escape key is 27.
11+
if cv2.waitKey(1) == 27:
12+
break
13+
14+
# Release the capture and destroy all OpenCV Windows.
15+
capture.release()
16+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)