0

I'm trying to figure out the code about face detection. Here is the code that I can not understand:

MatOfRect faces = new MatOfRect();

mJavaDetector.detectMultiScale(mGray, faces, 1.1, 2, 2, // TODO: objdetect.CV_HAAR_SCALE_IMAGE
                    new Size(mAbsoluteFaceSize, mAbsoluteFaceSize), new Size());
Rect[] facesArray = faces.toArray();

I'm wondering what does "faces" means and why have to turn it into Array by "faces.toArray"? Can anyone help me out? Thanks a lot.

Pelican
  • 43
  • 7
  • 1
    Looks like detectMultiScale detects multiple face matches in the input image mGray. I'm not too sure the details of the MatOfRect class, but I think you have to call it's toArray() method to obtain the detected faces as an array of rectangles (each rectangle is a detected face). The conversion to array is probably for easier iteration over the matches. – Stralo Aug 07 '15 at 00:50
  • I agree with @Stralo – Mido Aug 07 '15 at 02:53

1 Answers1

0

Haar cascade detector detects "face" from the mgray(image) and stores it in faces(MatofRect), MatofRect hold 4 points namely(x,y,widht,height). These four points can be used to draw the rectangle around the detected "face".There can be more than one possible matches so it stored in array of Rect.

Jubilee r
  • 55
  • 6