Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 检测到人脸时拍照_Android_Camera_Android Camera_Face Detection - Fatal编程技术网

Android 检测到人脸时拍照

Android 检测到人脸时拍照,android,camera,android-camera,face-detection,Android,Camera,Android Camera,Face Detection,我有以下代码,当检测到人脸时,我只想自动拍摄一张照片。 我已经实现了自动拍照,但它拍摄了很多照片,没有时间处理它们,因为它不断检测人脸。我怎样才能让它每x分钟搜索一张脸或每x分钟拍照一次?先谢谢你 FaceDetectionListener faceDetectionListener = new FaceDetectionListener(){ @Override public void onFaceDetection(Face[] faces, Camera camera)

我有以下代码,当检测到人脸时,我只想自动拍摄一张照片。 我已经实现了自动拍照,但它拍摄了很多照片,没有时间处理它们,因为它不断检测人脸。我怎样才能让它每x分钟搜索一张脸或每x分钟拍照一次?先谢谢你

FaceDetectionListener faceDetectionListener
= new FaceDetectionListener(){

    @Override
    public void onFaceDetection(Face[] faces, Camera camera) {

        if (faces.length == 0){
            prompt.setText(" No Face Detected! ");
        }else{
            //prompt.setText(String.valueOf(faces.length) + " Face Detected :) ");
              try{
                camera.takePicture(myShutterCallback,myPictureCallback_RAW, myPictureCallback_JPG);

               }
               catch(Exception e){

               }
        }


    }};

然后,您可以在
myShutterCallback
中执行任何处理,并调用
faceDetectionListener.setProcessing(false)
拍摄另一张照片。这将保证一次只拍摄一张照片。

如果我在您给我写信时运行它,它根本不会拍摄照片。我做错了什么?
FaceDetectionListener faceDetectionListener
= new FaceDetectionListener(){

    private boolean processing = false;

    public void setProcessing(boolean processing) {
        this.processing = processing;
    }

    @Override
    public void onFaceDetection(Face[] faces, Camera camera) {
        if (processing) return;

        if (faces.length == 0){
            prompt.setText(" No Face Detected! ");
        }else{
            //prompt.setText(String.valueOf(faces.length) + " Face Detected :) ");
              try{
                   camera.takePicture(myShutterCallback,myPictureCallback_RAW, myPictureCallback_JPG);
                   processing = true;
               }
               catch(Exception e){

               }
        }


    }};