1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.hand.face.utils;
import android.content.Context;
import android.hardware.Camera;
import android.hardware.Camera.Face;
import android.hardware.Camera.FaceDetectionListener;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
/**
* Created by USER on 2016/12/10.
*/
public class GoogleFaceDetect implements FaceDetectionListener {
private static final String TAG = "YanZi";
private Context mContext;
private Handler mHander;
public GoogleFaceDetect(Context c, Handler handler){
mContext = c;
mHander = handler;
}
@Override
public void onFaceDetection(Face[] faces, Camera camera) {
// TODO Auto-generated method stub
Log.i(TAG, "onFaceDetection...");
if(faces != null){
Message m = mHander.obtainMessage();
m.what = EventUtil.UPDATE_FACE_RECT;
m.obj = faces;
m.sendToTarget();
}
}
/* private Rect getPropUIFaceRect(Rect r){
Log.i(TAG, "人脸检测 = " + r.flattenToString());
Matrix m = new Matrix();
boolean mirror = false;
m.setScale(mirror ? -1 : 1, 1);
Point p = DisplayUtil.getScreenMetrics(mContext);
int uiWidth = p.x;
int uiHeight = p.y;
m.postScale(uiWidth/2000f, uiHeight/2000f);
int leftNew = (r.left + 1000)*uiWidth/2000;
int topNew = (r.top + 1000)*uiHeight/2000;
int rightNew = (r.right + 1000)*uiWidth/2000;
int bottomNew = (r.bottom + 1000)*uiHeight/2000;
return new Rect(leftNew, topNew, rightNew, bottomNew);
}*/
}