9

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.

Ayse
  • 311
  • 1
  • 3
  • 17
  • 2
    Can the downvoter leave a feedback please? So that I can improve the question. – Ayse Mar 30 '13 at 13:55
  • you use this link,may be is helpful for you. http://www.edumobile.org/android/android-programming-tutorials/face-detection-example-tutorials-in-android/ – anupam sharma Mar 12 '14 at 08:05

2 Answers2

17

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
}
Tushar
  • 8,019
  • 31
  • 38
  • Thanks for your reply. I thought that maybe there is a formula in which we use EULER or eyeDistance in order to identify a person.. Is there any solution that can you suggest to me for the problem? – Ayse Mar 21 '13 at 08:38
  • @aysealmac I don't think you can uniquely identify faces using just the pose and the distance between eyes, but I'm not an expert in the science between facial recognition either. – Tushar Mar 21 '13 at 08:43
  • Tushar do you have demo of this ? – Ronak Mehta Nov 22 '13 at 07:53
8

As Tushar said, the FaceDetector only detects the faces. You can't recognize them using FaceDetector though. The eye distance output is measured in pixels, not in cm or inches. It represents how big the face is inside the bitmap image. The euler angles are supposed to represent the 3D rotation of the head. However, if your app uses any api before 14, the euler angles values will always be 0.0 (they are not computed). So, take care with this.

If you want to do face recognition, you can use opencv. I haven't used it myself, but I think it is available on Android. Face Recognition in OpenCV http://docs.opencv.org/trunk/modules/contrib/doc/facerec/

If you don't want or can't add OpenCV to your project, you can program the face recognition by yourself. It take some time, but it's not so hard. You can implement some variation of eigenfaces: http://www.youtube.com/watch?v=LYgBqJorF44&list=PLd3hlSJsX_Imk_BPmB_H3AQjFKZS9XgZm&index=16

Good luck!

Community
  • 1
  • 1