我已经使用camera2 API对摄像机进行了编程,但是当我执行onCaptureCompleted或onCaptureProgressed方法时,除了LENS_FOCAl_LENGTH之外的值都为空。
@Override
public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) {
super.onCaptureCompleted(session, request, result);
String aperture = String.valueOf(result.get(CaptureResult.LENS_APERTURE));
String focal_length = String.valueOf(result.get(CaptureResult.LENS_FOCAL_LENGTH));
String focus_distance = String.valueOf(result.get(CaptureResult.LENS_FOCUS_DISTANCE));
String exposure_time = String.valueOf(result.get(CaptureResult.SENSOR_EXPOSURE_TIME));
String frame_duration = String.valueOf(result.get(CaptureResult.SENSOR_EXPOSURE_TIME));
String sensitivity = String.valueOf(result.get(CaptureResult.SENSOR_SENSITIVITY));
}
答案 0 :(得分:0)
您需要在其他设备上进行测试。 根据文档(https://developer.android.com/reference/android/hardware/camera2/CaptureResult),几乎所有值“可选-此键的值在某些设备上可能为null。”
例如,在您的情况下不为null的LENS_FOCAL_LENGTH是“此密钥在所有设备上都可用”。因此,所有值都取决于设备类型。