-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.py
68 lines (53 loc) · 2.63 KB
/
config.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from __future__ import print_function
import secret
import cv2
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]
class Config(object):
__metaclass__ = Singleton
live_preview_with_detection = False
send_email_notifications = False
classifierNameLocationDict = {
'motion_detector': {'description': 'Motion detector'},
# Face
'face_detection': {'description': 'Face detection (haarcascade)',
'location': 'models/haar/haarcascade_frontalface_default.xml'},
'lbpcascade_frontalface_improved': {'description': 'Face detection (lbp)',
'location': 'models/lbp/lbpcascade_frontalface_improved.xml'},
# Haar
'full_body_detection': {'description': 'Full body detection',
'location': 'models/haar/haarcascade_fullbody.xml'},
'haarcascade_upperbody': {'description': 'Upper body detection',
'location': 'models/haar/haarcascade_upperbody.xml'},
'haarcascade_smile': {'description': 'Smile detection',
'location': 'models/haar/haarcascade_smile.xml'},
# lbp
'lbpcascade_frontalcatface': {'description': 'Cat face detection',
'location': 'models/lbp/lbpcascade_frontalcatface.xml'},
'lbpcascade_silverware': {'description': 'Silverware detection',
'location': 'models/lbp/lbpcascade_silverware.xml'}
}
classifier_name = 'motion_detector'
classifier = None
classifier2 = None
def set_classifier(self, classifier_name):
self.classifier_name = classifier_name
if classifier_name == 'motion_detector':
self.classifier = None
self.classifier2 = None
else:
self.classifier = cv2.CascadeClassifier(self.classifierNameLocationDict[classifier_name]['location'])
self.classifier2 = cv2.CascadeClassifier(self.classifierNameLocationDict[classifier_name]['location'])
email_send_interval = 60
sender_email_address = secret.from_email
sender_email_password = secret.from_email_password
receiver_email_address = secret.to_email
def to_string(self):
attributes = vars(self)
print(self.__class__.__name__ + ' attributes: ')
print(', '.join("%s: %s" % item for item in attributes.items()))
print(self.__dict__)