In Android you can get a description of the properties of a Camera
by retrieving a CameraInfo
. I'm interested in orientation, as described at http://developer.android.com/reference/android/hardware/Camera.CameraInfo.html#orientation
However the documentation seems inconsistent with how all four of my devices behave, and, I have news of a fifth device for which this seemly fixed value changes.
In particular, the documentation says:
The value is the angle that the camera image needs to be rotated
clockwise so it shows correctly on the display in its natural
orientation. ... For example, suppose a device has a naturally tall
screen. The back-facing camera sensor is mounted in landscape. You are
looking at the screen. If the top side of the camera sensor is aligned
with the right edge of the screen in natural orientation, the value
should be 90. If the top side of a front-facing camera sensor is
aligned with the right of the screen, the value should be 270.
But in the stated example, it is the camera image that is rotated 90 degrees clockwise relative to the naturally tall orientation, not the other way around. That is, the image, whose top is aligned with the right hand side of the device, needs 270 degrees clockwise rotation to align with the device's top side.
At least, all four of my devices report "90" for this value, and all act as if the camera's top is the right side of the device when held in natural orientation. That is, the image must be rotated 270 degrees clockwise, not 90, to match the natural orientation. The example seems correct; the first line does not.
This example code seems to support my conclusion as it only gives the right result when orientation is interpreted as above.
Strangely, I have log evidence from one user's device that shows it reporting this value as 90 at times, and 0 at other times! It ought to be a physical property of how the camera is seated in the device, right?
- Can anyone confirm that the first line of the documentation is in fact wrong, and the example is right?
- Has anyone observed a changing value of
CameraInfo.orientation
? Is there evidence in docs that this is legal behavior, or is it likely a bug in the device?
- Any other related comments, experiences, gotchas I have not run into yet?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…