Search code examples
pythonpython-2.7opencvcropface-recognition

Cropping face Using OPENCV python


I am using opencv for face detection, and in addition I want to crop the faces and save them,

How can I do it?

The form of the face array: for (x, y, w, h) in faces


Solution

  • id = 1    
    for (x,y,w,h) in faces:
        cropped = img[ y : y+h, x : x+w ]
        cv2.imwrite("cropped_face" + str(id) + ".png", cropped)
        id++