feat: add cam2api autofocus

This commit is contained in:
cnwxu3ea 2024-07-25 06:10:50 +08:00
parent cb6ef11cdd
commit 7ac553ce9d

View file

@ -481,6 +481,7 @@ public class Camera2Session {
captureRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_VIDEO_RECORD);
isStabilizationAvailable(builder);
isAutoFocusAvailable(builder);
}
if (sensorSize != null && Math.abs(currentZoom - 1f) >= 0.01f) {
@ -528,6 +529,18 @@ public class Camera2Session {
}
}
private void isAutoFocusAvailable(CaptureRequest.Builder builder) {
if (setModeIfAvailable(
builder,
CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES,
CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_VIDEO,
CaptureRequest.CONTROL_AF_MODE)) {
FileLog.d("Camera2Sessions use continuous AF");
} else {
FileLog.d("Camera2Sessions AF is not available");
}
}
private boolean setModeIfAvailable(
CameraCharacteristics.Key<int[]> key, int desiredMode,
CaptureRequest.Builder builder, CaptureRequest.Key<Integer> requestKey) {