-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
22 lines (18 loc) · 701 Bytes
/
test.py
File metadata and controls
22 lines (18 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import cv2
for i in range(3): # Loop through available cameras
cap = cv2.VideoCapture(i)
if cap.isOpened():
print(f"Opening Camera {i}...")
while True:
ret, frame = cap.read()
if not ret:
print(f"Camera {i} failed to capture.")
break
cv2.putText(frame, f"Camera {i}", (50, 50),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
cv2.imshow(f"Camera {i}", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"): # Press 'q' to close the camera window
break
cap.release()
cv2.destroyAllWindows()