-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
50 lines (33 loc) · 811 Bytes
/
Copy pathmain.py
File metadata and controls
50 lines (33 loc) · 811 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import cv2
from camera import get_frame, release_camera
from ai_recognition import recognize
FRAME_SKIP = 15
frame_count = 0
last_name = "Unknown"
while True:
frame = get_frame()
if frame is None:
break
frame_count += 1
# Run AI only every 15 frames
if frame_count % FRAME_SKIP == 0:
print("Running AI Recognition...")
last_name = recognize(frame)
# Display last recognized name
color = (0, 255, 0)
if last_name == "Unknown":
color = (0, 0, 255)
cv2.putText(
frame,
last_name,
(40, 50),
cv2.FONT_HERSHEY_SIMPLEX,
1,
color,
2
)
cv2.imshow("SentinelAI Camera", frame)
if cv2.waitKey(1) & 0xFF == ord("q"):
break
release_camera()
cv2.destroyAllWindows()