Search code examples
androidface-detectioncamera2

camera2 face detection call back


I'm trying to use the face detector in the camera2 api. I set the preview builder to use the face detector:

                        previewBuilder.set(CaptureRequest.STATISTICS_FACE_DETECT_MODE,
                        CameraMetadata.STATISTICS_FACE_DETECT_MODE_FULL);
                        CR = previewBuilder.build();
                        CS = session;
                        CS.setRepeatingRequest(CR, CScallback, null);

But I don't understand where the code hits when it detects a face? Does it return a face in the CameraCaptureSession.CaptureCallback? Where does it send back the info about the detected faces?


Solution

  • http://developer.android.com/reference/android/hardware/camera2/CaptureResult.html

    So it seems that the face data is only available after the picture is taken or in other words not while the preview is happening. When you set face detect mode on for the preview builder that means the captureresult will get the metadata when the picture is taken. I will try to find a way to do it while in preview, I think I can take snapshots of the preview and run a face detection using a background thread. I will open a separate question for that scenario.