5

I've read its possible to use the built in android face detector to find the position of faces in a bitmap. Does anyone know of any examples of doing this using the camera as an input?

bzlm
  • 9,626
  • 6
  • 65
  • 92
Peter
  • 5,071
  • 24
  • 79
  • 115

1 Answers1

1

Its possible with the Face Detection APIs in ICS. Refer the camera section on this page: http://developer.android.com/sdk/android-4.0.html

You must register a FaceDetectionListener and then call camera.startFaceDetection(). Please read the link above for more details.

I wrote some sample code. It isn't perfect since its Work In Progress but the face detection bit works just fine:

https://docs.google.com/open?id=0B2Nu5U2Cz81qZExGQ25sWVdRd21IOExUUTZsZzFoZw

Anirudh
  • 2,524
  • 1
  • 14
  • 14
  • 1
    I know face detector is available in earlier API levels than ICS, is there a reason this is limited to ICS? – Peter Mar 05 '12 at 17:59
  • Face Detection from the camera preview is a new feature in ICS. It also depends on the chipset's camera drivers. Sometimes, new useful framework components like Fragments etc are released for earlier version using the compatibility package but I don't see that happening for face detection (from preview) APIs. – Anirudh Mar 05 '12 at 21:14
  • Oh okay got it. Thanks for all the help. One last question so i tried running it on my newly upgraded asus transformer and it crashes every time giving me an error about 0 faces. Is there any way to fix this? I thought maybe switching cameras may help, i posted the question here http://stackoverflow.com/questions/9578097/android-face-detection-maxnumdetectedfaces – Peter Mar 06 '12 at 05:21
  • There is an older face detection capability that goes back to API 1. It's called [FaceDetector](http://developer.android.com/reference/android/media/FaceDetector.Face.html) and it doesn't require hardware support so it's available on all phones. – Christian Aug 01 '12 at 18:03
  • @Christian it seems it works only if the image is already created , and not while the camera preview is "running" . is it possible to show the detected faces while the camera preview is "running" , even on old APIs ? – android developer Dec 13 '12 at 16:42
  • @android Not with the older API that I know of. You have to use the new API for that. – Christian Dec 21 '12 at 12:00
  • that's too bad . however i think i do remember that some camera apps have this feature , maybe even of samsung? – android developer Dec 22 '12 at 00:05
  • Guys, is there a possibility to constantly scan for eyes' activity? – Jake Mar 13 '13 at 09:07
  • Existing quesiton: http://stackoverflow.com/questions/15380889/scanning-eyes-activity-with-android-facedetector-face-api – Jake Mar 13 '13 at 09:43
  • Does this actually draw a rectangle around the person's face? Not working for me. – egfconnor Nov 18 '13 at 04:33
  • Note that there is now a new face detector available: https://developers.google.com/vision/ – pm0733464 Aug 20 '15 at 15:41