Skip to content

Face detection #1646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions image_processing/face_detection/detect_face.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# simple face detectin algorithm to detect the presence of at least a face in an image provided.
'''
:input => image path
:output => boolean corresponding to the detection of a face or not
TRUE if face(s) detected. else FALSE
'''
import cv2
def detect_face(image):
gray = cv2.cvtColor(cv2.imread(image), cv2.COLOR_BGR2GRAY)
cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')
faces = cascade.detectMultiScale(gray, 1.03, 3)
return len(faces) > 0

if __name__ == "__main__":
print(detect_face('im1.jpg'))
Loading