Upside down camera preview byte array [duplicate]
Asked Answered
S

1

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.

Small answered 24/11, 2015 at 20:7 Comment(5)
We have the same problem, also with Camera2 API. It appears that CameraInfo.orientation and CameraCharacteristics.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".Hamil
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.Small
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 answerHamil
Thanks for the link, seems pretty good!Small
This might help you captechconsulting.com/blogs/…Borough
U
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://mcmap.net/q/664846/-nexus-5x-reverse-landscape-sensor-fix-in-a-android-camera-preview-app

Uropod answered 2/11, 2016 at 10:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.