Get angle of view of android camera device

后端 未结 3 2055
说谎
说谎 2021-02-15 15:08

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.

3条回答
  •  粉色の甜心
    2021-02-15 15:53

    You could do it mathematically.

    Diagram

    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!

提交回复
热议问题