@@ -44,7 +44,7 @@ class FaceDetect:
44
44
'face-extraction' : False ,
45
45
'print' : True ,
46
46
'face-features' : [],
47
- 'known-faces' : {'D1' : 'path1 ' , 'D2' : 'path2 ' }
47
+ 'known-faces' : {'D1' : 'resources/person1.png ' , 'D2' : 'resources/person2.png ' }
48
48
}
49
49
ACCEPTED_VIDEO_FORMAT = ['avi' , 'mp4' , 'mov' ]
50
50
ACCEPTED_IMAGE_FORMAT = ['jpeg' , 'jpg' , 'gif' , 'png' ]
@@ -69,12 +69,16 @@ def __init__(self, settings=None):
69
69
# Populating setting from input (overrides are possible)
70
70
if settings :
71
71
for setting in settings :
72
- setting = setting .lower ()
73
72
74
- # Sanitize if string, otherwise take as is
75
- val = settings [ setting ] .lower (). strip () if isinstance ( settings [ setting ], str ) else settings [ setting ]
73
+ # Sanitize the key
74
+ sanitized_setting = setting .lower ()
76
75
77
- self .settings [setting ] = val
76
+ # Get the value and sanitize if string, otherwise take as is
77
+ val = settings .get (setting )
78
+ val = val .lower ().strip () if type (val ) is str else val
79
+
80
+ # Set the settings to the sanitized keys and values
81
+ self .settings [sanitized_setting ] = val
78
82
79
83
####################################################
80
84
# Public methods for face detection and recognition
@@ -244,12 +248,12 @@ def __detect(self):
244
248
self .face_labels .append (label )
245
249
246
250
# Upon face detection
247
- if self .face_locations :
248
251
249
- # Condense the face locations and labels into tuples
250
- self .detections = zip (self .face_locations , self .face_labels )
252
+ # Condense the face locations and labels into tuples
253
+ self .detections = zip (self .face_locations , self .face_labels ) if self . face_locations else None
251
254
252
- # Format onto tuples if there are self detections
255
+ # Format onto tuples if there are self detections
256
+ if self .detections :
253
257
self .detections = [(detection [0 ], detection [1 ]) for detection in self .detections ]
254
258
255
259
def __callback (self ):
@@ -300,7 +304,8 @@ def __execute_setting(self):
300
304
301
305
def __recognize (self ):
302
306
""" Calls the face recognition """
303
- print ('recognizing' )
307
+
308
+ print ('recognize' )
304
309
return self
305
310
306
311
####################################################
0 commit comments