title: Rotate VideoCapture in OpenCV on Android
body: <p>How to rotate the camera when using class VideoCapture on OpenCV? (Sample Face Detection on Android). 
  I'm rotating the canvas with:</p>
  
  <pre><code>if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
  {
      Matrix matrix = new Matrix();
      matrix.preTranslate(
      (canvas.getWidth() - bmp.getWidth()) / 2,
      (canvas.getHeight() - bmp.getHeight()) / 2);
      matrix.postRotate(270f, (canvas.getWidth()) / 2,
      (canvas.getHeight()) / 2);
      canvas.drawBitmap(bmp, matrix, null);
  }
  </code></pre>
  
  <p>but image from Camera doesn't rotate: Face Detect dont work.</p>
  
  <p>The camera receives the stream from the following:</p>
  
  <pre><code>protected Bitmap processFrame(VideoCapture capture) {
  
      capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
  
      capture.retrieve(mGray,
      Highgui.CV_CAP_ANDROID_GREY_FRAME);
  </code></pre>
  
  <p>UPDATE 
  I did the following:</p>
  
  <pre><code>@Override
      protected Bitmap processFrame(VideoCapture capture) {
  
      if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
          Core.flip(mRgba.t(), mRgba, 0);
      }
  
      else {
      }
      capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
      capture.retrieve(mDetect_thread.mGray,
              Highgui.CV_CAP_ANDROID_GREY_FRAME);
  </code></pre>
  
  <p>But is dont work. When I run the program in portret orientation(on android device)- program don't start When i run the rogram in landscape orientation - programm work, but when i rotation the device, program work, but image on display dont rotation</p>