Update face_grab.py
Browse files- face_grab.py +8 -7
face_grab.py
CHANGED
@@ -41,13 +41,14 @@ class FaceGrabber:
|
|
41 |
detected = (detected.rect.left(), detected.rect.top(), detected.rect.width(), detected.rect.height())
|
42 |
logging.info("Face detected by mmod")
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
51 |
|
52 |
if detected is not None: # if face detected
|
53 |
x, y, w, h = detected # grab first face
|
|
|
41 |
detected = (detected.rect.left(), detected.rect.top(), detected.rect.width(), detected.rect.height())
|
42 |
logging.info("Face detected by mmod")
|
43 |
|
44 |
+
if detected is None:
|
45 |
+
for cascade in self.cascades:
|
46 |
+
cascadeClassifier = cv.CascadeClassifier(cv.data.haarcascades + cascade)
|
47 |
+
faces = cascadeClassifier.detectMultiScale(img, scaleFactor=1.5, minNeighbors=5) # detect faces
|
48 |
+
if len(faces) > 0:
|
49 |
+
detected = faces[0]
|
50 |
+
logging.info(f"Face detected by {cascade}")
|
51 |
+
break
|
52 |
|
53 |
if detected is not None: # if face detected
|
54 |
x, y, w, h = detected # grab first face
|