-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathface_detector_main.py
34 lines (32 loc) · 1.08 KB
/
face_detector_main.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 multiprocessing import Queue, Process
from face_detector import face_detector, read_cam
import signal
import cv2
if __name__ == '__main__':
print "main"
frames = Queue(10)
faces = Queue()
frame_getter_process = Process(target=face_detector, args=(frames, faces, True, "./faces/"))
face_detector_process = Process(target=read_cam, args=(frames,))
frame_getter_process.daemon = True
face_detector_process.daemon = True
original_signal_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
frame_getter_process.start()
face_detector_process.start()
signal.signal(signal.SIGINT, original_signal_handler)
try:
frame_getter_process.join()
face_detector_process.join()
cv2.destroyAllWindows()
exit(1)
except Exception, e:
print e
frame_getter_process.terminate()
face_detector_process.terminate()
frame_getter_process.join()
face_detector_process.join()
if e is KeyboardInterrupt:
exit(1)
else:
cv2.destroyAllWindows()
exit(2)