【问题标题】:onFaceDetection(Camera.Face[] faces, Camera camera) keeps on executing continuouslyonFaceDetection(Camera.Face[] faces, Camera camera) 继续执行
【发布时间】:2016-11-15 21:31:36
【问题描述】:

我正在创建一个应用程序捕获图像,因为它检测到人脸并且我能够实现这一点,但是即使在摄像头前面没有人脸,FaceDetectionListener 的 OnFaceDetection 函数也只会继续执行一个问题。我正在粘贴我的代码。

mCamera.setFaceDetectionListener(new Camera.FaceDetectionListener() {
    @Override
    public void onFaceDetection(Camera.Face[] faces, Camera camera) {
            try {
                if (lastCaptureTiume + 10000 <= System.currentTimeMillis() || !faceCaptured) {
                    mCamera.takePicture(null, null, jpegCallback);
                    lastCaptureTiume = System.currentTimeMillis();
                    faceCaptured = true;
                }   
            }
            catch (Exception e) {
            }
    }
});

问题是尽管镜头前没有人脸,但它仍在继续拍照。

【问题讨论】:

    标签: android camera android-camera face-detection


    【解决方案1】:

    对于不同的设备,这种行为是不同的。对于我的 Note 3,onFaceDetection 即使在没有人脸的情况下也会继续执行,而对于 nexus 手机,它的性能非常好。 好吧,我没有任何其他解决方案,所以我设置了面部检查条件。

         if (faces != null && faces.length > 0) {
            //Do code here
         }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多