David Biga David Biga - 1 month ago 12
Android Question

Converting Focal Length in millimeters to pixels - Android

In Android, I am currently accessing the

camera's
focal length by using
getFocalLength()
in
Camera1
.
Camera2
is not an option.

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
from
mm
->
px
. Now I know the
focal_length_m
variable but I am currently trying to figure out the
pixel_width_m
which is is the width of a pixel (on the sensor) in meters.

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()

Comments