Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Bitmap;

import android.graphics.PointF;
import android.media.FaceDetector;

public class Main {
    private static PointF findFaceMid(Bitmap in) {
        PointF mid = new PointF();
        Bitmap bitmap565 = in.copy(Bitmap.Config.RGB_565, true);

        FaceDetector fd = new FaceDetector(in.getWidth(), in.getHeight(), 1);
        FaceDetector.Face[] faces = new FaceDetector.Face[1];
        fd.findFaces(bitmap565, faces);

        FaceDetector.Face face = faces[0];
        if (face != null) {
            try {
                face.getMidPoint(mid);
                return mid;
            } catch (NullPointerException n) {
            }
        }
        return null;

    }
}