diff --git a/imageProcess.py b/imageProcess.py index df0530fc2948904b77d7c8cefe866d643caeb925..c2670e39a55aecd5ffc9b69c7762154965c83e26 100644 --- a/imageProcess.py +++ b/imageProcess.py @@ -31,4 +31,23 @@ 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) \ No newline at end of file + 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