title: How reliable is Android camera2 CameraCharacteristics API for sensor size?
body: <p>I'm trying to get/compute the FOV for devices's cameras using <code>camera2</code> API my code at the bottom).</p>
  
  <p>On my attempt on a Galaxy S7 :</p>
  
  <ul>
  <li>the given sensor size is 3.2mm x 2.4mm (using <code>SENSOR_INFO_PHYSICAL_SIZE</code>).</li>
  <li>In this case, my computed HFOV is 41.7° (focal length given is 4.2mm) which I proved wrong by experimentation.</li>
  <li>Various spec doc mention a 1/2.5" sensor size (5.76mm x 4.29mm according to <a href="https://en.wikipedia.org/wiki/Image_sensor_format" rel="noreferrer">wikipedia</a>) - which would give me a HFOV of 68.9°, closer to my experiments.</li>
  <li>the values in <code>CameraCharacteristics</code> seem wrong.</li>
  </ul>
  
  <p>The same queries and experiments on a Samsung Galaxy A3-2016 are more conclusive, the calculated HFOV seems to match the experimental one.</p>
  
  <p>Has anyone experience or data to share about the reliability of <code>CameraCharacteristics</code> readings ?</p>
  
  <hr>
  
  <p>The code I used to query <code>CameraCharacteristics</code> ::</p>
  
  <pre><code>CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraID);
  if (characteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT)
      continue;
  
  int support = characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
  if( support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY )
      Log.d("mr", "Camera " + cameraID + " has LEGACY Camera2 support");
  else if( support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED )
      Log.d("mr", "Camera " + cameraID + " has LIMITED Camera2 support");
  else if( support == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_FULL )
      Log.d("mr", "Camera " + cameraID + " has FULL Camera2 support");
  else
      Log.d("mr", "Camera " + cameraID + " has unknown Camera2 support?!");
  
  // voir http://myandroidarchive.tistory.com/5 pour le query android
  // voir http://paulbourke.net/miscellaneous/lens/ pour les maths
  // include every focal length supported by the camera device, in ascending order.
  float[] focalLengths = characteristics.get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS);
  SizeF sensorSize = characteristics.get(CameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE);
  
  float w = 0.5f * sensorSize.getWidth();
  float h = 0.5f * sensorSize.getHeight();
  Log.d("mr", "Camera " + cameraID + " has sensorSize == " + Float.toString(2.0f*w) + ", " + Float.toString(2.0f*h));
  for (int focusId=0; focusId&lt;focalLengths.length; focusId++) {
      float focalLength = focalLengths[focusId];
      float horizonalAngle = (float) Math.toDegrees(2 * Math.atan(w / focalLength));
      float verticalAngle = (float) Math.toDegrees(2 * Math.atan(h / focalLength));
      Log.d("mr", "Camera " + cameraID + "/f" + focusId + " has focalLength == " + Float.toString(focalLength));
      Log.d("mr", "  * horizonalAngle == " + Float.toString(horizonalAngle));
      Log.d("mr", "  * verticalAngle == " + Float.toString(verticalAngle));
  }
  </code></pre>