-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_camera.py
More file actions
36 lines (26 loc) · 759 Bytes
/
test_camera.py
File metadata and controls
36 lines (26 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# test_camera.py
import cv2
print("🎥 Testing webcam capture...")
print("Press 'q' to quit")
# Initialize webcam (0 is usually the default camera)
cap = cv2.VideoCapture(0)
# Check if camera opened successfully
if not cap.isOpened():
print("❌ Error: Could not open webcam")
exit()
print("✅ Webcam opened successfully!")
while True:
# Capture frame-by-frame
ret, frame = cap.read()
if not ret:
print("❌ Error: Can't receive frame")
break
# Display the frame
cv2.imshow('FitMentor - Camera Test', frame)
# Break loop on 'q' key press
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release everything
cap.release()
cv2.destroyAllWindows()
print("✅ Camera test complete!")