Android examples for android.media:FaceDetector
find Faces from Bitmap
import java.util.ArrayList; import android.graphics.Bitmap; import android.media.FaceDetector; import android.media.FaceDetector.Face; import android.util.Log; public class Main { private static final String TAG = ""; private static FaceDetector mFacesDetector; public static final int NUM_FACES = 10; public static ArrayList<Face> findFaces(Bitmap bitmap) { ArrayList<Face> facesList = new ArrayList<Face>(); long startTime = System.currentTimeMillis(); if (bitmap != null) { Face[] faces = new Face[10]; mFacesDetector = new FaceDetector(bitmap.getWidth(), bitmap.getHeight(), 10); int numberOfFaces = mFacesDetector.findFaces(bitmap, faces); Log.d(TAG, "Finding faces took " + (System.currentTimeMillis() - startTime) + " ms."); for (int i = 0; i < numberOfFaces; i++) { facesList.add(faces[i]);/*from www. j a v a2s .co m*/ } } return facesList; } }