-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_video.py
More file actions
30 lines (21 loc) · 726 Bytes
/
main_video.py
File metadata and controls
30 lines (21 loc) · 726 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
import cv2
from simple_facerec import SimpleFacerec
# Encode faces from a folder
sfr = SimpleFacerec()
sfr.load_encoding_images("images/")
# Load Camera
cap = cv2.VideoCapture(2)
while True:
ret, frame = cap.read()
# Detect Faces
face_locations, face_names = sfr.detect_known_faces(frame)
for face_loc, name in zip(face_locations, face_names):
y1, x2, y2, x1 = face_loc[0], face_loc[1], face_loc[2], face_loc[3]
cv2.putText(frame, name,(x1, y1 - 10), cv2.FONT_HERSHEY_DUPLEX, 1, (0, 0, 200), 2)
cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 0, 200), 4)
cv2.imshow("Frame", frame)
key = cv2.waitKey(1)
if key == 27:
break
cap.release()
cv2.destroyAllWindows()