Reputation: 21
I'm using OPENCV to detect a face in a picture and I want ot extract it, so i have the photo with a man and the expected result is a jpg image with only the seleted face
I have detect the face but if someone can help me to extract this face and save it!
Thank you all
Upvotes: 0
Views: 1380
Reputation: 21203
You just have to add a single line to your program.
Consider a variable detected_face
, and do the following:
detected_face = img[y:y+h, x:x+w]
cv2.imwrite('face.jpg', detected_face)
You will have a .jpg
file of ONLY the face stored in your directory
Upvotes: 1