I'm using FaceDetect (Python) which finds a face in an image and creates a box around it (as below).
Unlike the image below, the images I want to use all have a single face. Is there a simple way to save the produced image and crop it to what is inside the box?
Line 26 on face_detect.py - Looks like it has the dimensions you need...
# Draw a rectangle around the faces
for (x, y, w, h) in faces:
cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
You need to replace the rectangle()
function with logic to crop instead. You should be able to pass in the dimensions into a numpy array function to do the crop. Here's an example of cropping in OpenCV using hard coded dimensions...