-
-
Save sazio/a7e28981b5ea21edc215675b78de77be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# OpenCV face detector | |
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml") | |
def detect_face_cv2(img): | |
# Move to grayscale | |
gray_img = cv2.cvtColor(img.copy(), cv2.COLOR_RGB2GRAY) | |
face_locations = [] | |
face_rects = face_cascade.detectMultiScale(gray_img, scaleFactor=1.3, minNeighbors=5) | |
for (x,y,w,h) in face_rects: | |
face_location = (x,y,w,h) | |
face_locations.append((face_location, 1.0)) | |
return face_locations |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment