我正在尝试使用底部的camera2
API来获取/计算设备摄像机的FOV。
我尝试使用Galaxy S7时:
SENSOR_INFO_PHYSICAL_SIZE
)。CameraCharacteristics
中的值似乎有误。三星Galaxy A3-2016上的相同查询和实验更具决定性,计算出的HFOV似乎与实验相符。
是否有人有经验或数据可以分享CameraCharacteristics
读数的可靠性?
我用来查询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));
}
答案 0 :(得分:3)
Scanbot的开发人员(也就是我使用相机足够了)。
根据我的经验,Camera API的任何内容都不可靠,因为这个API在硬件和供应商特定的相机驱动程序上是一个相对薄的层。换句话说,API的输出将取决于供应商决定放在哪里,而不是(与Android SDK的其他部分不同)由Google管理。