Ask Your Question
0

how can i save detected face in opencv

asked 2015-05-12 03:50:40 -0600

manish137 gravatar image

hello, i am using Haar cascade program for detecting face which is shown in window. But i want to save the detected face. And after i want to send this pic via gprs module. Thanks

edit retag flag offensive close merge delete

Comments

1

for saving it on local you shall look at imwrite function

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-05-12 04:15:09 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-05-12 04:24:37 -0600

Keeping in mind that all faces are stored as rectangles you can do the following

// Your detection code
Mat original_image;
vector<Rect> faces;
detectMultiScale(...);

// Loop over detections and store them
for (size_t i=0; i < faces.size(); i++){
   // Define the face you found
   Rect roi = faces[i];
   // Cut it out of the original image
   Mat face = original_image(roi).clone();
   // Store the image
   imwrite("path_to_image_location", face);
}
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-05-12 03:50:40 -0600

Seen: 2,466 times

Last updated: May 12 '15