-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera_Testing.py
More file actions
43 lines (29 loc) · 1.02 KB
/
Camera_Testing.py
File metadata and controls
43 lines (29 loc) · 1.02 KB
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
37
38
39
40
41
42
43
import cv2
def main():
# Open the Arducam video feed (typically at /dev/video0)
cap = cv2.VideoCapture(0, cv2.CAP_V4L2) # Change '0' to the correct camera ID if needed
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*'MJPG'))
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 800)
cap.set(cv2.CAP_PROP_FPS, 120)
# Check if the camera is opened
if not cap.isOpened():
print("Error: Could not open camera.")
return
print("Press 'q' to exit.")
while True:
# Capture frame-by-frame
ret, frame = cap.read()
if not ret:
print("Error: Could not read frame.")
break
# Display the resulting frame
cv2.imshow('Arducam Live Feed', frame)
# Exit the loop when 'q' is pressed
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release the capture and close the window
cap.release()
cv2.destroyAllWindows()
if __name__ == "__main__":
main()