David Biga - 8 months ago 73

Android Question

In Android, I am currently accessing the

`camera's`

`getFocalLength()`

`Camera1`

`Camera2`

I am trying to full fill the current calculation:

`focal_length_pix = focal_length_m * 1 (pix) / pixel_width_m`

Basically this converts the

`focal length`

`mm`

`px`

`focal_length_m`

`pixel_width_m`

I am struggling to find a way to calculate the width of a pixel on the sensor. Any suggestions, ideas would be much appreciated.

Answer

Was able to calculate the `focal length`

in `pixels`

by the following:

`double focal_length_pix = (size.width * 0.5) / tan(horizontalAngleView * 0.5 * PI/180);`

`size`

derives from `getPreviewSize()`

Source (Stackoverflow)