Commonlife's Blog

My daily life

Posts Tagged ‘facedetector

android : FaceDetector

leave a comment »

FaceDetector : Api Level 1 : http://developer.android.com/reference/android/media/FaceDetector.html

*  Bitmap.Config.RGB_565 으로 decoding 되어야만 가능.

BitmapFactory.Options bitmapLoadingOptions = new BitmapFactory.Options();
bitmapLoadingOptions.inPreferredConfig = Bitmap.Config.RGB_565;
mBitmap = BitmapFactory.decodeFile(imageLocalPath, bitmapLoadingOptions);

// Ready
private int maxfaces = 10;     // 최대로 찾을 얼굴 갯수
FaceDetector myFaceDetector = new FaceDetector(mBitmap.getWidth(), mBitmap.getHeight(), maxfaces); //
FaceDetector.Face detectedFace = new FaceDetector.Face[maxfaces];
PointF faceMidPoint = new PointF();

// Find
int number_of_faces = myFaceDetector.findFaces(mBitmap, detectedFace);     // 여기서 얼굴을 찾음.
if(number_of_faces <= 0) {
} else {
    for(int i=0; i < number_of_faces; i++){
        FaceDetector.Face tempFace = detectedFace[i];
        tempFace.getMidPoint(faceMidPoint);
        int eyes_distance = tempFace.eyesDistance();
    }
}

* detectedFace에 찾은 얼굴들이 저장된다.

Written by tocommonlife

2013/01/29 at 06:59

Android에 게시됨

Tagged with ,