8

So I'm using androids built in facedector to detect and determine the position of faces in a bitmap. Right now it works and will tell me: confidence, eyesDistance and midpoint but whenever i try to get the pose it always returns 0 no matter what images i try using.

This is the code I use to get the pose:

poseString = "Pose: (" + getFace.pose(FaceDetector.Face.EULER_X) + ","
                        + getFace.pose(FaceDetector.Face.EULER_Y) + ","
                        + getFace.pose(FaceDetector.Face.EULER_Z) + ")";

And here is the code I use:

arrayFaces = new FaceDetector(picWidth, picHeight, NUM_FACES);
        arrayFaces.findFaces(sourceImage, getAllFaces);

        for (int i = 0; i < getAllFaces.length; i++) {
            getFace = getAllFaces[i];
            try {
                PointF eyesMP = new PointF();
                getFace.getMidPoint(eyesMP);
                poseString = "Pose: ("+ getFace.pose(FaceDetector.Face.EULER_X) + ","
                        + getFace.pose(FaceDetector.Face.EULER_Y) + ","
                        + getFace.pose(FaceDetector.Face.EULER_Z) + ")";
                EULER_X = getFace.EULER_X;
                EULER_Y = getFace.EULER_Y;
                EULER_Z = getFace.EULER_Z;      

                eyesDistance[i] = getFace.eyesDistance();
                eyesMidPts[i] = eyesMP;

                if (DEBUG) {
                    currentx = eyesMidPts[i].x;
                    currenty = eyesMidPts[i].y;
                    betweeneyes = getFace.eyesDistance();

                    Log.d("currentx", currentx + "");
                    Log.d("currenty", currenty + "");
                    Log.d("betweeneyes", betweeneyes + "");
                    Log.d("EULER", "EULER_X: " + EULER_X + "EULER_Y: " + EULER_Y + "EULER_Z: " + EULER_Z);

                    Log.i("Face", i + " " + getFace.confidence() + " "
                            + getFace.eyesDistance() + " " + "Pose: ("
                            + getFace.pose(FaceDetector.Face.EULER_X) + ","
                            + getFace.pose(FaceDetector.Face.EULER_Y) + ","
                            + getFace.pose(FaceDetector.Face.EULER_Z) + ")"
                            + "Eyes Midpoint: (" + eyesMidPts[i].x + ","
                            + eyesMidPts[i].y + ")");
                }
            } catch (Exception e) {
                if (DEBUG)
                    Log.e("Face", i + " is null");
            }




        }
Peter
  • 4,740
  • 22
  • 74
  • 114
  • Can we see the code where you're actually using the `FaceDetector`? As far as I can tell from the docs, you should be passing in your own `Face[]` array and then reading directly from those objects. – sastraxi Apr 03 '12 at 01:04
  • check this code as it work for me and other people too http://stackoverflow.com/questions/9269891/android-face-detection/9272063#9272063 – Tofeeq Ahmad Apr 07 '12 at 11:13
  • @Sameer I don't see `Pose` used anywhere in that code. – Peter Apr 08 '12 at 22:19

1 Answers1

3

A cursory google search shows about 10 different posts--some even on StackOverflow--of people with the same problem. Did you find these? It looks like it might be a bug. I suggest you report it to the android bug tracker.

Edit: You should definitely file a bug. Take a look at the face detection source code: this source file shows that Android will never set these to anything but 0.

Until this changes, there are other CV options for Android. Check out OpenCV for Android, which is now officially supported by the team.

Community
  • 1
  • 1
sastraxi
  • 1,304
  • 11
  • 21
  • Thanks I'll look into that, I had looked into OpenCV for Android before but I could never get it set up and actually working, do you know of any good resources? – Peter Apr 03 '12 at 01:22
  • Are you using Eclipse? If you are, have you tried the step-by-step guide that the website I linked you to provides? – sastraxi Apr 03 '12 at 02:18
  • Yes I am, But I see that their website has changed and looks like its been updated since the last time I tried to get it working. I would still like to get the `pose` working with android facedetect since I have all of the other code already working. But I will definitely look into OpenCV for the future. – Peter Apr 03 '12 at 14:23
  • See my revised answer, Peter--seems like you're going to have to change your approach if you want euler angles. – sastraxi Apr 03 '12 at 18:04