我的问题是如何在检测到脸部时拍照并将其保存到设备中,当我们拍摄第1张照片时,由于我们无法保存到许多图片到设备,所以当检测到脸部时,将在5秒后拍摄下一张照片。
答案 0 :(得分:0)
你必须在相机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<Rect> faceRects;
faceRects = new ArrayList<Rect>();
for (int i=0; i<faces.length; 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中。 如果您有任何疑问,请告诉我。