我已经用camera2api对相机进行了编程,但是当我执行oncapturecompleted或oncaptureprogressed方法时,值获取除镜头焦距以外的空值。
@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));
}
在此处输入图像描述
1条答案
按热度按时间kkih6yb81#
你需要在其他设备上测试。根据文件(https://developer.android.com/reference/android/hardware/camera2/captureresult)几乎所有的值都是“可选的-此键的值在某些设备上可能为空。”
但举例来说,透镜焦距在你的例子中不是空的是“这个键在所有设备上都可用”,所以所有的值都取决于设备类型。