你必须在相机API中添加FaceDetectionListener然后调用startFaceDetection()方法,
CameraFaceDetectionListener fDListener = new CameraFaceDetectionListener();
mCamera.setFaceDetectionListener(fDetectionListener);
mCamera.startFaceDetection();
实现Camera.FaceDetectionListener,您在onFaceDetection覆盖方法中接收检测到的面,
private class MyFaceDetectionListener
implements Camera.FaceDetectionListener {
@Override
public void onFaceDetection(Face[] faces, Camera camera) {
if (faces.length == 0) {
Log.i(TAG, "No faces detected");
} else if (faces.length > 0) {
Log.i(TAG, "Faces Detected = " +
String.valueOf(faces.length));
public List faceRects;
faceRects = new ArrayList();
for (int i=0; i
int left = faces[i].rect.left;
int right = faces[i].rect.right;
int top = faces[i].rect.top;
int bottom = faces[i].rect.bottom;
Rect uRect = new Rect(left0, top0, right0, bottom0);
faceRects.add(uRect);
}
// add function to draw rects on view/surface/canvas
}
}
根据你的情况,新的Handler() . postDelayed(新的Runnable,长秒)在5秒后将第二张图片放在runnable中 . 如果您有任何疑问,请告诉我 .