rot*_*lup 5 android android-sensors android-camera2
我正在尝试使用camera2API(底部的代码)来获取/计算设备相机的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));
}
Run Code Online (Sandbox Code Playgroud)
Scanbot 的开发人员在这里(也就是我使用相机足够了)。
根据我的经验,关于相机 API 的任何东西都不可靠,主要是因为这个 API 是硬件和供应商特定相机驱动程序上的一个相对较薄的层。换句话说,API 的输出将取决于哪个供应商决定放置在那里,并且不受 Google 管理(与 Android SDK 的其余部分不同)。
| 归档时间: |
|
| 查看次数: |
1279 次 |
| 最近记录: |