-
Notifications
You must be signed in to change notification settings - Fork 2
/
local_recognizer.py
34 lines (29 loc) · 957 Bytes
/
local_recognizer.py
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
from detector.detect import FaceDetector
from recognizer.recognize import FaceRecognizer
import cv2
import os
from matplotlib import pyplot as plt
import numpy as np
import time
if __name__ == '__main__':
detector = FaceDetector(keep_top_k = 4)
recognizer = FaceRecognizer()
cap = cv2.VideoCapture(0)
buff_size = 10
while True:
detector.prepare_buffer()
while len(detector.buffer_faces) < buff_size:
ret, frame = cap.read()
if not ret:
print('read error')
break
detector.process_img(frame)
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
time.sleep(0.2)
buffer = detector.buffer_faces
recognizer.update_facebank()
recognizer.buffer_faces = buffer
names = recognizer.recognize_faces_by_location()
print('names', names)