The FaceDetector
class doesn't do what you think it does. Specifically, it doesn't do Facial Recognition, but instead Facial Detection (hence the class name).
It analyzes an image and returns Face
s found in the image. It makes no distinction between Face
s (you can't tell if it's John's Face
or Sarah's Face
) other than the distance between their eyes - but that isn't really a valid comparison point. It just gives you the Faces found and the confidence level that the objects found are actually Face
s.
Ex:
int maxNumFaces = 2; // Set this to whatever you want
FaceDetector fd = new FaceDetector(imageWidth,imageHeight,maxNumFaces);
Faces[] faces = new Faces[maxNumFaces];
try {
int numFacesFound = fd.findFaces(image, faces);
for (int i = 0; i < maxNumFaces; ++i) {
Face face = faces[i];
Log.d("Face " + i + " found with " + face.confidence() + " confidence!");
Log.d("Face " + i + " eye distance " + face.eyesDistance());
Log.d("Face " + i + " pose " + face.pose());
Log.d("Face " + i + " midpoint (between eyes) " + face.getMidPoint());
}
} catch (IllegalArgumentException e) {
// From Docs:
// if the Bitmap dimensions don't match the dimensions defined at initialization
// or the given array is not sized equal to the maxFaces value defined at
// initialization
}