title: How to use camera resource with FaceDetector in android?
body: <p>I want to use <code>FaceDetector</code> in android.
   I tried <code>FaceDetector</code> with a bitmap image and its working fine. </p>
  
  <p>(with the help of: <a href="http://code.tutsplus.com/tutorials/an-introduction-to-face-detection-on-android--cms-25212" rel="nofollow">http://code.tutsplus.com/tutorials/an-introduction-to-face-detection-on-android--cms-25212</a>)</p>
  
  <p>Now, I want to detect face, when camera is on. The documentation writes:</p>
  
  <blockquote>
    <p>Alternatively, a detector may be used within a pipeline structure, in 
    conjunction with sources (e.g., CameraSource) and processors (e.g.,
    LargestFaceFocusingProcessor), enabling you to construct fairly
    advanced detection pipelines with minimal coding. For example, the
    code below creates and starts a pipeline that continuously receives
    preview frames from a camera source for the front facing camera, runs
    detection on the frames, manages tracking of the most prominent face,
    and delivers continuous update notifications over time to a
    developer-defined "FaceTracker" instance.</p>
  </blockquote>
  
  <p><a href="https://developers.google.com/android/reference/com/google/android/gms/vision/face/FaceDetector" rel="nofollow">https://developers.google.com/android/reference/com/google/android/gms/vision/face/FaceDetector</a></p>
  
  <p>The code it provides:</p>
  
  <pre><code>detector.setProcessor(
     new LargestFaceFocusingProcessor(
       detector,
       new FaceTracker()));
  
   CameraSource cameraSource = new CameraSource.Builder(context, detector)
     .setFacing(CameraSource.CAMERA_FACING_FRONT)
     .setRequestedPreviewSize(320, 240)
     .build()
     .start();
  </code></pre>
  
  <p>I want to implement this in my code:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          FaceDetector detector = new FaceDetector.Builder(this)
                  .setProminentFaceOnly(true)
                  .build();
          detector.setProcessor(
                  new LargestFaceFocusingProcessor(
                          detector,
                          new FaceTracker()));
  
          try {
              CameraSource cameraSource = new CameraSource.Builder(this, detector)
                      .setFacing(CameraSource.CAMERA_FACING_FRONT)
                      .setRequestedPreviewSize(320, 240)
                      .build()
                      .start();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  
      class FaceTracker extends Tracker
      {
          public void onDone ()
          {
  
          }
  
  
      }
  
  }
  </code></pre>
  
  <p>but, unable to move forward. Can you please help me to code it further? </p>