Home » Android » Get angle of view of android camera device

Get angle of view of android camera device

Posted by: admin June 15, 2020 Leave a comment


I want to know the angle of view from the camera, just like in this question but using android.hardware.camera2. How can I reproduce the next code using the new camera2 library.

Camera.Parameters p = camera.getParameters();
double thetaV = Math.toRadians(p.getVerticalViewAngle());
double thetaH = Math.toRadians(p.getHorizontalViewAngle());

Is there a way to do the same thing?

How to&Answers:

I search the google a person show possibility which he calculate FOV by Camera2 api


and found the equation


FOV (rectilinear) = 2 * arctan (frame size/(focal length * 2))

thus, we need to know frame size and focal length

the frame size is size of camera you can find the code on below link


also, focal length you can find below link

Manual focus in camera2, android

and i combine the code like this

A function calculateFOV() calculate FOV angle



As far as my research has gone the answer is no. With the camera2 API there is no call which can give you the vertical and horizontal viewing angle.

However, you don’t need to use the camera2 API to get those values. You can just use the original camera API to get the vertical and horizontal view angle and then use the camera2 API for the rest of the app.

As far as I know the actual image capture firmware hasn’t changed between the camera and camera2 APIs.


You could do it mathematically.


You have:

  • L, the width of an object
  • d, the distance to the object

You want to calculate the angle a (alpha), the field of view.

Doing some trig:

tan(a/2) = (L/2)/d
tan(a/2) = L/2d
a/2 = atan(L/2d)
a = 2*atan(L/2d)

You can do that to calculate the horizontal field of view. Good luck!