Android Camera Angle Returns Pi

I need to get the horizontal and vertical angles of a camera for an application I'm writing. I used this approach in the second (not accepted) answer to this question , which worked fine. I AM:

Camera.Parameters p = Camera.open().getParameters();

      

and then can call

Math.toRadians(p.getVerticalViewAngle());

      

or an equivalent horizontal method to obtain the viewing angles.

This worked on my Nexus 4 and Samsung tablet, but I decided to try the app on my Nexus 7 and both the horizontal and vertical angles return as pi. Obviously, this is a ludicrous value for these attributes. Any idea why I am getting these values ​​for this device?

Also, maybe the linked note android.hardware.Camera

is deprecated and replaced with android.hardware.Camera2

. I haven't been able to find a way to achieve the same goal with Camera2

, though, but would welcome any suggestions on how to do this.

+3


source to share


1 answer


p.getVerticalViewAngle()

will probably return the maximum value for any possible camera.

Pi's answer implies that it has 360 ° vision, which is incredible but possible and will be the theoretical maximum the camera can take.

Therefore, I would recommend trying to open with ID:



Camera.Parameters p = Camera.open(/**cameraNumber**/).getParameters();

      

and make sure the CameraDevice is not null.

As for another question, there is no way to use the camera2 api to get vertical and horizontal viewing angles, but using the original camera API it works (at least it worked for me).

+2


source







All Articles