Skip to content

Commit 6d3ab9b

Browse files
authored
Merge pull request #124 from lucidcode/feature/highlight-detection-algorithms
Highlight detection algorithm
2 parents c19f31d + 06e32ea commit 6d3ab9b

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

software/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def get(self, setting):
7979
print(str(e))
8080

8181
if self.default[setting] != None:
82+
self.config[setting] = self.default[setting]
8283
return self.default[setting]
8384

8485
return ""

software/face.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def __init__(self, config, comms):
1616
self.ml_model = None
1717
self.min_confidence = 0.4
1818
self.threshold_list = [(math.ceil(self.min_confidence * 255), 255)]
19+
self.detector = ""
1920

2021
self.extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.GRAYSCALE)
2122

@@ -39,6 +40,7 @@ def detect(self, img, global_variance):
3940

4041
for (x, y, w, h), score in detection_list:
4142
self.face_object = (x - w, y - h, w * 4, h * 4)
43+
self.detector = "TensorFlow"
4244
self.has_face = True
4345
return
4446

@@ -57,6 +59,7 @@ def detect(self, img, global_variance):
5759

5860
if face_objects:
5961
self.face_object = face_objects[0]
62+
self.detector = "HaarCascade"
6063
self.has_face = True
6164

6265
if self.config.get('TrackEyes'):
@@ -76,7 +79,11 @@ def draw_region(self, img):
7679
if self.face_object[2] == img.width():
7780
return
7881

79-
img.draw_rectangle(self.face_object, color=(70, 130, 180))
82+
if self.detector == "TensorFlow":
83+
img.draw_rectangle(self.face_object, color=(70, 130, 180))
84+
85+
if self.detector == "HaarCascade":
86+
img.draw_rectangle(self.face_object)
8087

8188
if self.correct_angle:
8289
face_x = self.face_object[0]

0 commit comments

Comments
 (0)