I'm trying to get/compute the FOV for devices's cameras using camera2
API my code at the bottom).
On my attempt on a Galaxy S7 :
SENSOR_INFO_PHYSICAL_SIZE
).CameraCharacteristics
seem wrong.The same queries and experiments on a Samsung Galaxy A3-2016 are more conclusive, the calculated HFOV seems to match the experimental one.
Has anyone experience or data to share about the reliability of CameraCharacteristics
readings ?
The code I used to query CameraCharacteristics
::
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<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));
}
camera2 API for new applications. This class was deprecated in API level 21. We recommend using the new android.
Camera2 is the latest low-level Android camera package and replaces the deprecated Camera class. Camera2 provides in-depth controls for complex use cases, but requires you to manage device-specific configurations. You can read about specific Camera2 classes and functions in the reference documentation.
Developer of Scanbot here (aka I worked with camera enough).
From my experience nothing about Camera API can be reliable mostly because this API is a relatively thin layer upon hardware and vendor specific camera driver. In other words, output of API will depend on what vendor decided to put there and is not (unlike the rest of the Android SDK) governed by Google.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With