Face recognition using android sdk not opencv

Ayse picture Ayse · Mar 20, 2013 · Viewed 22.8k times · Source

I am currently work on face recognition in android. I spent reasonable time on internet and I found FaceDetector.Face class in Android. And these are the utilities of this class:

 Constants
 float  CONFIDENCE_THRESHOLD
 int    EULER_X The x-axis Euler angle of a face.
 int    EULER_Y The y-axis Euler angle of a face.
 int    EULER_Z The z-axis Euler angle of a face.

 Public Methods
 float   confidence()
 float   eyesDistance()
 void    getMidPoint(PointF point)
 float   pose(int euler)

The problem is, I do not know how to use these methods and I cannot find any tutorial or example source code for this. The question is, should I use eyesDistance() for differenciating the people? For example Sarah's eyesDistance is= 6.51 cm and John's is= 6.82. When the code calculates a persons eyes distance and when it is 6.82, is it tell you that "it is john" is this the way for identifind the people? Or what is the algorithm for that? Or should I use EULER constants? In what way? I think I am going to use these methods for face recognition, but I do not know how to use it.

Or can you suggest another solution for face recognition? Any help would be appreciated.

Answer

Tushar picture Tushar · Mar 21, 2013

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).

An example of Facial Detection

It analyzes an image and returns Faces found in the image. It makes no distinction between Faces (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 Faces.

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
}