Reputation: 1963
I have been working on a college project using OpenCV. I made a simple program which detects faces, by passing frames captured by a webcam in a function which detects faces.
On detection it draws black boxes on the faces when detected. However my project does not end here, i would like to be able to clip out those faces which get detected as soon as possible and save it in an image and then apply different image processing techniques [as per my need]. If this is too problematic i could use a simple image instead of using frames captured by a webcam.
I am just clueless about how to go about clipping those faces out that get detected.
Upvotes: 3
Views: 2053
Reputation: 8563
http://nashruddin.com/OpenCV_Region_of_Interest_(ROI)
Check this link, you can crop the image using the dimensions of the black box, resize it and save as a new file.
Upvotes: 1
Reputation: 30122
For C++ version you can check this tutorial from OpenCV documentation.
In the function detectAndDisplay
you can see the line
Mat faceROI = frame_gray( faces[i] );
where faceROI
is clipped face and you can save it to file with imwrite
function:
imwrite("face.jpg", faceROI);
Upvotes: 1
Reputation: 1434
Could you grab the frame and crop the photo with the X,Y coordinates of each corner?
Upvotes: 0