0

I am creating an application capture image as it detect the face and I am able to achieve that, but only one issue the OnFaceDetection function of FaceDetectionListener is keep on executing even if there is no face in-front of camera. I am pasting my code.

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) {
            }
    }
});

The issue is it is keep on takeing picture although there is no face in front of camera.

Rahul Sonone
  • 2,685
  • 1
  • 27
  • 38

1 Answers1

0

This behavior is different for different devices For my Note 3 onFaceDetection keeps on executing even without face and for nexus phone its performing perfectly. Well I didn't got any other solution so I put a face check condition.

     if (faces != null && faces.length > 0) {
        //Do code here
     }
Rahul Sonone
  • 2,685
  • 1
  • 27
  • 38