Search code examples
androidc++opencvface-detection

OpenCV4Android - capturing images in rectangles (face detection)


I've been using OpenCV C/C++ in the past, and currently I'm trying Android. I am detecting face features. I use OpenCV example for face detection and I am detecting features via cascades. What I want to ask you is:

1) how to capture area in reactangle to variable/device memory:

In OpenCV it worked like that:

cvSetImageROI(img1, cvRect(10, 15, 150, 250));

IplImage *img2 = cvCreateImage(cvGetSize(img1),
                           img1->depth,
                           img1->nChannels);
cvCopy(img1, img2, NULL);

In Android example I have array with rectangles of found faces:

Rect[] facesArray = faces.toArray();
for (int i = 0; i < facesArray.length; i++)
Core.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3);

But I have no clue how to save it because I cant work on IplImage. Can you guide me a bit about it or give me some source which I can study?

2) if there is any way to set onClick on areas which were found on the camera view, so I can click on choosen face, at write it to some kind of variable or save it in memory


Solution

  • i think, you're looking for mRgba.submat(facesArray[i])

    (very biased personal opinion: you're still using IplImages (aka c-api) ? whaa. bad habit. move over to the c++ api!)