i'm trying to gray the faces of all people in an image. While I can detect their faces and gray them into smaller mat(s), I'm unable to 'copy' the grayed faces to the original mat. Such that the end result will have a mat with all faces in gray.
faceDetector.detectMultiScale(mat, faceDetections);
for (Rect rect : faceDetections.toArray())
{
Rect rectCrop = new Rect(rect.x, rect.y, rect.width, rect.height);
Mat imageROI = new Mat(mat,rectCrop);
//convert to B&W
Imgproc.cvtColor(imageROI, imageROI, Imgproc.COLOR_RGB2GRAY);
//Uncomment below will grayout the faces (one by one) but my objective is to have them grayed out on the original mat only.
//Highgui.imwrite(JTestUtil.DESKTOP_PATH+"cropImage_"+(++index)+".jpg",imageROI);
//add to mat? doesn't do anything :-(
mat.copyTo(imageROI);
}