I need to get the camera's horizontal and vertical viewing angles for an app I am writing. I used the approach in the second (not the accepted) answer on this question, which was working fine. I do:
Camera.Parameters p = Camera.open().getParameters();
and can then call
Math.toRadians(p.getVerticalViewAngle());
or the equivalent horizontal method to get the viewing angles.
This worked on my Nexus 4 and on a Samsung tablet, but I decided to try the app on my Nexus 7 and both the horizontal and vertical angles are being returned as pi. Obviously this is a ridiculous value for these attributes. Any idea why I am getting these values for this device?
Also, on a perhaps related note, android.hardware.Camera
has been deprecated and replaced by android.hardware.Camera2
. I have been unable to find a way of achieving the same goal with Camera2
though, but would welcome any suggestions on how to do this.