顔を検出すると、顔の周りに長方形を描くために使用される長方形の対角が得られます。
これで、画像の ROI (関心領域) を設定し、ROI を切り取り、別の画像として保存できます。
/* After detecting the rectangle points, Do as follows */
/* sets the Region of Interest
Note that the rectangle area has to be __INSIDE__ the image */
cvSetImageROI(img1, cvRect(10, 15, 150, 250));
/* create destination image
Note that cvGetSize will return the width and the height of ROI */
IplImage *img2 = cvCreateImage(cvGetSize(img1),
img1->depth,
img1->nChannels);
/* copy subimage */
cvCopy(img1, img2, NULL);
/* always reset the Region of Interest */
cvResetImageROI(img1);
上記のコードはhttp://nashruddin.com/OpenCV_Region_of_Interest_(ROI )から取得したものです。
さらにcvSaveImage機能を使用して、画像をファイルに保存できます。