Get the viewing angle of a device for an Android camera

I want to know the viewing angle from the camera, as in this question, but using android.hardware.camera2. How can I reproduce the following 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 any way to do the same?

+6
source share
3 answers

As far as my research has gone, the answer is no. camera2 no call with camera2 API that can give you vertical and horizontal viewing angle.

However, you do not need to use the camera2 API to get these values. You can simply use the original camera API to get the vertical and horizontal viewing angle, and then use the camera2 API for the rest of the application.

As far as I know, the actual image firmware has not changed between the camera and camera2 API.

+5
source

You can do it mathematically.

Diagram

You have:

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

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

Executing some trigger:

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

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

+4
source

I am looking in google for the opportunity to show the person that he calculates FOV using Camera2 api

https://photo.stackexchange.com/questions/54054/calculating-the-field-of-view-for-a-nexus-5

and found the equation

http://www.bobatkins.com/photography/technical/field_of_view.html

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

so we need to know the frame size and focal length

frame size - camera size, you can find the code below the link

fooobar.com/questions/990117 / ...

Also, the focal length you can find below the link

Manual focus in camera2, android

and I combine code like this

The calculateFOV () function calculates the FOV angle

https://github.com/pchan1401-ICIL/Camera2FOV

+2
source

All Articles