Ask Your Question

Revision history [back]

What you want to do is first of all resize your cap image to the size of the detected face surface. Besides that it is just copying regions of interest.

// These variables should be somewhere in your code
Mat detection_image;
Rect detection_found;
Mat cap = imread('location_of_file', 1);
// Now perform the copying
Mat resized_cap;
resize(cap, resized_cap, Size(detection_found.width, detection_found.height));
Mat destination_roi = detection_image( detection_found );
resized_cap.copyTo(destination_roi);
// Visualize
imshow("result", detection_image);
waitKey(0);