20

I have a camera application which is locked to landscape. When needed I rotate the raw bytes gotten from on onPreviewFrame() and use them to encode a video.

This approach however fails in the Nexus 5X and 6 devices, because their reversed sensor gives me upside-down frames.

As rotating the preview won't help me in this case, as described here:

This does not affect the order of byte array passed in onPreviewFrame(byte[], Camera)

I'd like to know if there's any way to detect that the camera sensor is reversed and/or the raw frame is upside down, so an extra correction is added when rotating them.

DoDo
  • 2,248
  • 2
  • 22
  • 34
Edson Menegatti
  • 4,006
  • 2
  • 25
  • 40
  • 2
    We have the same problem, also with Camera2 API. It appears that [CameraInfo.orientation](https://developer.android.com/reference/android/hardware/Camera.CameraInfo.html#orientation) and [CameraCharacteristics.SENSOR_ORIENTATION](https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SENSOR_ORIENTATION) do not give correct information about true sensor orientation (we get 90 for both back and front camera on Nexus 6). So far the only option we know of is having a list of "special case devices". – DoDo Nov 26 '15 at 11:36
  • 1
    I noticed that the majority of the phones that I have available for testing return 90 for back-facing camera and 270 for front-facing cameras. I'm wondering that this is an indicative of its rotation. – Edson Menegatti Nov 26 '15 at 11:51
  • 3
    It appears this is correct. On Nexus 6, front camera returns 90, and on other devices it returns 270. Maybe this can be used for determining orientation. Check also [this SO answer](http://stackoverflow.com/a/13176590/213057) – DoDo Nov 26 '15 at 15:09
  • Thanks for the link, seems pretty good! – Edson Menegatti Nov 26 '15 at 16:54
  • 1
    This might help you https://www.captechconsulting.com/blogs/android-camera-orientation-made-simple – Alex Townsend Jul 07 '16 at 19:30

1 Answers1

1

the camera sensor of the Nexus 5x and 6 are rotated 180 degrees. A lot of apps had this problem when the device was released. You should take this into account while creating a camera app and set your surface rotation accordingly.

For more information go to https://stackoverflow.com/a/35431231/1492034

Community
  • 1
  • 1
LordSidious
  • 508
  • 5
  • 15