Skip to content
Snippets Groups Projects
Commit 176ba232 authored by Timothé Boulet's avatar Timothé Boulet :alien:
Browse files

add selectFace

parent 74de12d8
Branches
No related tags found
No related merge requests found
......@@ -32,3 +32,22 @@ def imageProcess(image):
#Write emotion on the image
emotion = fa.detectEmotion(face_color)
cv2.putText(image, emotion, (x,y), cv2.FONT_HERSHEY_SIMPLEX, 1, (255,0,0), 2)
def selectFace(image):
#Return a face identified on an colored image
#Import cv2 face detector
face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades+'haarcascade_frontalface_default.xml')
#Face detection is made on gray images
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5) #This return a list of tuple locating faces on image
#The face returned is the first face detected on the image (if exists)
if faces != []:
x,y,w,h = faces[0]
face = image[y:y+h, x:x+w]
return face
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment