ongkn commited on
Commit
4906dd6
1 Parent(s): f2ccb4c

Update face_grab.py

Browse files
Files changed (1) hide show
  1. 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
- for cascade in self.cascades:
45
- cascadeClassifier = cv.CascadeClassifier(cv.data.haarcascades + cascade)
46
- faces = cascadeClassifier.detectMultiScale(img, scaleFactor=1.5, minNeighbors=5) # detect faces
47
- if len(faces) > 0:
48
- detected = faces[0]
49
- logging.info(f"Face detected by {cascade}")
50
- break
 
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