title: How can i handle the rotation issue with Preview & FaceDetection
body: <p>i got some issue nagging me for quite some time now.</p>
  
  <p>I got my custom Camera-App that shows a live Preview. Aswell i am using the FaceDetection for getting a better focus on peoples faces. When i check my taken Pictures in Gallery i can see the Rectangle correctly. The next step is to make the FaceDetection-Rectangle visible in the Live-Preview. So i decided to use a canvas that gets the coordinates from the Preview-Rectangle and transform them to coordinates that can be used by the canvas.</p>
  
  <p>My problem is that i had to rotate the Preview by 90degrees that it shows the Preview correctly. So when i also rotate the View of the canvas before i draw it, the rectangle shows correctly and moves the right axis aswell. BUT the rectangle can move out of screen on left and right, and only uses about half of the available height. I assume that the rotating causes the trouble, but i can't manage to put things right. Someone got an idea?</p>
  
  <p>Screenshot (i added purple lines to show the top/bottom-parts that cant be reached by red rectangle):
  <img src="https://i.stack.imgur.com/YPaxa.jpg" alt="enter image description here"></p>
  
  <p><strong>Preview:</strong></p>
  
  <pre><code>        mCamera = Camera.open();
          mCamera.getParameters();
          mCamera.setDisplayOrientation(90);          
          mCamera.setFaceDetectionListener(new FaceDetectionListener() {
  
              @Override
              public void onFaceDetection(Face[] faces, Camera camera) {
  
                          if(mDraw != null) {
                              mDraw.update(f.rect, f);
                          }
                      }
                  }
              }
          });
          mCamera.startFaceDetection();
  }
  
  private DrawOnTop  mDraw = null;
  public void setDrawOnTop(DrawOnTop d) {
      this.mDraw = d;
  }
  </code></pre>
  
  <p><strong>DrawOnTop:</strong></p>
  
  <pre><code>public DrawOnTop(Context context) {
      super(context);
      myColor = new Paint();
  
      myColor.setStyle(Paint.Style.STROKE);
      myColor.setColor(Color.RED);
  }
  
  @Override
  protected void onDraw(Canvas canvas) {
          rect.set((((rect.left+1000)*1000) / WIDTH_DIVISOR),(((rect.top+1000)*1000) / HEIGHT_DIVISOR),(((rect.right+1000)*1000) / WIDTH_DIVISOR),(((rect.bottom+1000)*1000) / HEIGHT_DIVISOR ));         
          setRotation(90);
          canvas.drawRect(rect, myColor);
  }
  
  public void update(Rect rect, Face face) {
      this.invalidate();
      this.rect = rect;
      this.face = face;
  }
  </code></pre>
  
  <h2>----------------------------------------------------------------------------------------</h2>
  
  <hr>
  
  <p><strong>EDIT:</strong>
  i came to the conclusion that this is a rare but known bug and that there is so far no other solution but forcing the application to landscape-mode. Works ok, but dimensions look a bit stretched or clinched  depending on which perspective the user is operating.</p>