1

I'm new to Android-Emulator..Can anyone tell me how do i use "android.media.FaceDetector" ? And how do i combine a webcam preview together with the Face detection in android emulator?

richq
  • 55,548
  • 20
  • 150
  • 144
user683479
  • 11
  • 3

1 Answers1

2

I'm not sure what you're asking for; the api is fairly straight forward:

FaceDector fc = new FaceDetector(<width of your bitmap>, <height of your bitmap>, <max number of faces>);
Face[] faces = new Face[<max number of faces>];
int found = fc.findFaces(<your bitmap>, faces);
PointF point = new PointF();
for (int i = 0; i < found; ++i) {
  faces[i].getMidPoint(point);
  System.out.println("Point: " + point.x + ", " + point.y);
}
thoredge
  • 12,237
  • 1
  • 40
  • 55
  • can i use this method in android emulator 2.1? and how do i combine this method with a video stream? cause currently my program is running a thread for my video output, thus im having difficulty calling out the bitmap from my class method. – user683479 May 03 '11 at 02:02
  • You can run it, but I don't think you can access the camera (at least not on my machine). You'll need a still image bitmap to search for faces in, but you can grab that from a video stream (see http://stackoverflow.com/questions/2326523/android-video-stream-capture-for-ar and http://developer.android.com/reference/android/graphics/BitmapFactory.html). – thoredge May 03 '11 at 07:24