title: Button to switch between front and back camera in my camera app in android studio and face detection
body: <p>I'm developping a camera app on android studio using openCv 3.0.0.It's my first time doing this and I'm facing some problems. But I have 2 issues:
  1) I want to add a button to switch between the front camera and the back camera. But I can't seem to find a way to switch. </p>
  
  <p>Here is my onCreate method:</p>
  
  <pre><code>private Camera mCamera;
  private CameraPreview mPreview;
  private static int number = Camera.CameraInfo.CAMERA_FACING_FRONT;
  
   @Override
   public void onCreate(final Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
          setContentView(R.layout.face_detect_surface_view);
  
       // Create an instance of Camera
          mCamera = getCameraInstance(number);// This funtion opens the camera
  
          // Create our Preview view and set it as the content of our activity.
          mPreview = new CameraPreview(this, number , mCamera);
          final FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview);
  
          preview.addView(mPreview);
  
  
          // Add a listener to the Capture button
          ImageButton captureButton = (ImageButton) findViewById(R.id.button_capture);
          captureButton.setOnClickListener(
                  new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          Toast.makeText(getApplicationContext(), "Image captured!", Toast.LENGTH_SHORT).show();
                          // get an image from the camera
                          mCamera.takePicture(null, null, mPicture);
                      }
                  }
          );
  
  // Add a listener to the Change button
          ImageButton changeButton = (ImageButton) findViewById(R.id.button_change);
          changeButton.setOnClickListener(
                  new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          if (number == Camera.CameraInfo.CAMERA_FACING_FRONT)
                              number = Camera.CameraInfo.CAMERA_FACING_BACK;
                          else
                              number = Camera.CameraInfo.CAMERA_FACING_FRONT;
                         //HERE SHOULD BE THE STEPS TO SWITCH
                          Toast.makeText(getApplicationContext(), "Camera changed!", Toast.LENGTH_SHORT).show();
                          // get an image from the camera
  
                      }
                  }
          ); 
  }
  </code></pre>
  
  <p>2)I want to use openCv for face detection on the image that's captures but I don't know whether it's possible. I couldn't find anything on the web. I've already tried the example faceDetect from openCv 3.0.0 and it worked when I was using the camera. That's what I wanted to do at first but after I changed my layout to contain a frame layout instead of org.opencv.android.JavaCameraView it doesn't work anymore. So if anyone has an idea why I'd be very grateful.</p>