pvasa / cameraview-ex

Easy Android camera integration, advanced features.
Apache License 2.0
229 stars 49 forks source link

Camera1 preview wrong orientation on some devices #208

Open pcm2a opened 5 years ago

pcm2a commented 5 years ago

Describe the bug 9/12/19 Update: I was totally incorrect about what was going on. The ZTE Cymbal T runs android 5 but when it tries to use Camera2 it is falling back to Camera1. This issue here is with Camera1 and not Camera2. I have also validated that the Camera2 functionality works perfectly on a Nexus 6, only when using Camera1 is it upside down. Because of this I consider it a much lower of a priority.

Some devices have cameras installed in the device in non-standard orientations, usually with the front camera (selfie). Examples are some of the Nexus 5/6 devices and a test device I have, ZTE Cymbal T. The issue here is only with Camera1 and only with the preview. The recorded video is in the correct orientation.

I did some tests forcing the camera into Camera1 and then tested the fix on the broken device and on a device that did not have the problem.

Steps performed:

  1. Holding phone portrait, back camera:
  2. Holding phone portrait, switch to selfie camera:
  3. Rotate phone to landscape, switch to back camera
  4. Holding phone in landscape: switch to selfie camera:

With my changes in place : https://github.com/pvasa/cameraview-ex/pull/209

ZTE Cymbal T: Camera locked in portrait

  1. deviceRotation=0, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=90
  2. deviceRotation=0, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=270
  3. deviceRotation=90, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=90
  4. deviceRotation=90, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=270

Xaiomi: Camera locked in portrait

  1. rotationDegrees=0, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=90
  2. rotationDegrees=0, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=90
  3. rotationDegrees=90, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=90
  4. rotationDegrees=90, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=90

Try it out on a few devices forcing the camera to use Camera1 and see if it also works correctly for you.

Device (please complete the following information):

pcm2a commented 4 years ago

I have updated the issue, I was wrong about it being a Camera2 issue. It is only on a device that is using Camera1. Pretty low priority.