Android examples for android.media:FaceDetector
get Face Rect
//package com.java2s; import android.graphics.PointF; import android.graphics.Rect; import android.media.FaceDetector.Face; public class Main { private static final float GOLDEN_RATIO = 1.61803399f; public static Rect getFaceRect(Face face) { // GOLDEN_RATIO // float xRatio = ((float) getWidth()) / mBitmap.getWidth(); // float yRatio = ((float) getHeight()) / mBitmap.getHeight(); // TODO improve scaling by looking at pose and euler y PointF midPoint = new PointF(); face.getMidPoint(midPoint);//w ww . j a va2 s . c o m int x = (int) (midPoint.x - (face.eyesDistance())); int y = (int) (midPoint.y - (face.eyesDistance())); int width = x + (int) (face.eyesDistance() * 2); int height = y + (int) (face.eyesDistance() * 2 * GOLDEN_RATIO); return new Rect(x, y, width, height); } }