ソースを参照

Added flags for profile scans

Fred Damstra 7 年 前
コミット
d3d1b83530
1 ファイル変更12 行追加4 行削除
  1. 12 4
      facetracker.py

+ 12 - 4
facetracker.py

@@ -21,6 +21,8 @@ lastface = 0                # int 1-3 used to speed up detection. The script is
                         #         doesn't find it, it's set back to zero and on the next loop it will search for all three.-
                         #         This basically tripples the detect time so long as the face hasn't moved much.
 
+scanleft = True # Should we scan for left profiles?
+scanright = True # should we scan for right profiles?
 
 # initialize the camera and grab a reference to the raw camera capture
 camera = PiCamera()
@@ -52,12 +54,18 @@ def distance(p0, p1):
 
 def search_rightprofile(i):
 #    return profilefaceCascade.detectMultiScale(i,1.3,4,(cv2.CV_HAAR_DO_CANNY_PRUNING + cv2.CV_HAAR_FIND_BIGGEST_OBJECT + cv2.CV_HAAR_DO_ROUGH_SEARCH),(30,30))
-    return profilefaceCascade.detectMultiScale(i)
+    if scanright:
+        return profilefaceCascade.detectMultiScale(i)
+    else:
+        return ()
 
 def search_leftprofile(i):
-    revimage = cv2.flip(i, 1) # Flip the image
-#    return profilefaceCascade.detectMultiScale(i,1.3,4,(cv2.CV_HAAR_DO_CANNY_PRUNING + cv2.CV_HAAR_FIND_BIGGEST_OBJECT + cv2.CV_HAAR_DO_ROUGH_SEARCH),(30,30))
-    return profilefaceCascade.detectMultiScale(i)
+    if scanleft:
+        revimage = cv2.flip(i, 1) # Flip the image
+        #    return profilefaceCascade.detectMultiScale(i,1.3,4,(cv2.CV_HAAR_DO_CANNY_PRUNING + cv2.CV_HAAR_FIND_BIGGEST_OBJECT + cv2.CV_HAAR_DO_ROUGH_SEARCH),(30,30))
+        return profilefaceCascade.detectMultiScale(i)
+    else:
+        return ()
 
 def search_frontface(i):
 #    return frontalfaceCascade.detectMultiScale(i,1.3,4,(cv2.CV_HAAR_DO_CANNY_PRUNING + cv2.CV_HAAR_FIND_BIGGEST_OBJECT + cv2.CV_HAAR_DO_ROUGH_SEARCH),(30,30))