title: I can't detect face with camera2
body: <p>I can't find information about face detection on preview in android.hardware.Camera2, would anybody help me with a complete example?</p>
  
  <p>I saw some questions with camera2 examples in github but I can't understand them.</p>
  
  <p>I used Camera2 sample from Google: <a href="https://github.com/googlesamples/android-Camera2Basic" rel="nofollow">https://github.com/googlesamples/android-Camera2Basic</a>.</p>
  
  <p>I set face recognition mode to FULL.</p>
  
  <pre><code>mPreviewRequestBuilder.set(CaptureRequest.STATISTICS_FACE_DETECT_MODE, CameraMetadata.STATISTICS_FACE_DETECT_MODE_FULL);
  </code></pre>
  
  <p>Also I checked <code>STATISTICS_INFO_MAX_FACE_COUNT</code> and <code>STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES</code>:</p>
  
  <pre><code>int max_count = characteristics.get(
  CameraCharacteristics.STATISTICS_INFO_MAX_FACE_COUNT);
  int modes [] = characteristics.get(
  CameraCharacteristics.STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES); 
   Output: maxCount : 5 , modes : [0, 2]
  </code></pre>
  
  <p>My CaptureCallback:</p>
  
  <pre><code>private CameraCaptureSession.CaptureCallback mCaptureCallback = new CameraCaptureSession.CaptureCallback() {
  
  private void process(CaptureResult result) {
              Integer mode = result.get(CaptureResult.STATISTICS_FACE_DETECT_MODE);
              Face [] faces = result.get(CaptureResult.STATISTICS_FACES);
              if(faces != null &amp;&amp; mode != null)
                  Log.e("tag", "faces : " + faces.length + " , mode : " + mode ); 
  }
  
  @Override
  public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request,
                                  CaptureResult partialResult) {
      process(partialResult);
  }
  
  @Override
  public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
                                 TotalCaptureResult result) {
      process(result);
  }     `
  </code></pre>
  
  <p>Output: faces : 0 , mode : 2</p>
  
  <pre><code>public static final int STATISTICS_FACE_DETECT_MODE_FULL = 2; 
  </code></pre>
  
  <p>Faces length is constantly 0. Looks like it doesn't recognise a face properly or I missed something.</p>
  
  <p>I know approach with FaceDetector. I just wanted to check how it works with new camera2 Face.</p>
  
  <p>I need to detect face on preview of camera2!</p>