how to determine focal length given pixels code example Example: how to calculate focal length in pixels F(mm) = F(pixels) * SensorWidth(mm) / ImageWidth (pixel).