-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsensorshell.py
41 lines (34 loc) · 1015 Bytes
/
sensorshell.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
35
36
37
38
39
40
41
import cmd, sys
import cv2
import constants
import capture
import train
import time
from recognize import Recognizer
class SensorShell(cmd.Cmd):
intro = 'Hello, this is the sensor shell. Type ? or help to get a list of commands.\n'
prompt = '$ '
file = None
def do_capture(self, arg):
'Syntax: capture Name\nCapture a person with the specified name. (must be unique!)'
if arg != '':
capture.capture(arg)
else:
print("Syntax: capture Name")
def do_train(self, arg):
'Syntax: train\nTrain the model with all captured persons'
train.train()
def do_recognize(self, arg):
'Syntax: recognize\nStart the recognize loop and try periodically to recongize all persons in the image'
print("starting recognize loop, press 'C' to cancel")
recognizer = Recognizer()
key = 0
time.sleep(2.0)
while key != 'c' and key != 'C':
recognizer.recognize()
key = cv2.waitKey(1)
def do_exit(self, arg):
'Exits the shell'
sys.exit()
if __name__ == '__main__':
SensorShell().cmdloop()