blob: f4966eada8378051e8dbd9bd0f10864baa4108ba [file] [log] [blame]
giolekvaedbaf322020-05-05 18:17:37 +04001import cv2
2
3def detect_faces(img_file):
4 face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
5 img = cv2.imread(img_file)
6 gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
7 faces = face_cascade.detectMultiScale(gray, 1.1, 4)
8 ret = []
9 for (x, y, w, h) in faces:
10 ret.append((x, y, x + w, y + h))
11 return ret