import android.util.Log;
import android.util.Range;
import android.util.Size;
+import android.util.SizeF;
import java.util.ArrayList;
import java.util.Arrays;
* sensor.info.pixelArraySize
*/
m.set(SENSOR_INFO_PIXEL_ARRAY_SIZE, largestJpegSize);
+
+ /*
+ * sensor.info.physicalSize
+ */
+ {
+ /*
+ * Assume focal length is at infinity focus and that the lens is rectilinear.
+ */
+ float focalLength = p.getFocalLength(); // in mm
+ double angleHor = p.getHorizontalViewAngle() * Math.PI / 180; // to radians
+ double angleVer = p.getVerticalViewAngle() * Math.PI / 180; // to radians
+
+ float height = (float)Math.abs(2 * focalLength * Math.tan(angleVer / 2));
+ float width = (float)Math.abs(2 * focalLength * Math.tan(angleHor / 2));
+
+ m.set(SENSOR_INFO_PHYSICAL_SIZE, new SizeF(width, height)); // in mm
+ }
}
private static void mapStatistics(CameraMetadataNative m, Parameters p) {
}
// control.captureIntent
- m.set(CaptureRequest.CONTROL_CAPTURE_INTENT, templateId);
+ {
+ int captureIntent;
+ switch (templateId) {
+ case CameraDevice.TEMPLATE_PREVIEW:
+ captureIntent = CONTROL_CAPTURE_INTENT_PREVIEW;
+ break;
+ case CameraDevice.TEMPLATE_STILL_CAPTURE:
+ captureIntent = CONTROL_CAPTURE_INTENT_STILL_CAPTURE;
+ break;
+ case CameraDevice.TEMPLATE_RECORD:
+ captureIntent = CONTROL_CAPTURE_INTENT_VIDEO_RECORD;
+ break;
+ default:
+ // Can't get anything else since it's guarded by the IAE check
+ throw new AssertionError("Impossible; keep in sync with sAllowedTemplates");
+ }
+ m.set(CaptureRequest.CONTROL_CAPTURE_INTENT, captureIntent);
+ }
// control.aeMode
m.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
// TODO: Don't add control.awbLock to availableRequestKeys if it's not supported
}
+ // control.captureIntent
+ {
+ int captureIntent = ParamsUtils.getOrDefault(request,
+ CONTROL_CAPTURE_INTENT,
+ /*defaultValue*/CONTROL_CAPTURE_INTENT_PREVIEW);
+
+ captureIntent = filterSupportedCaptureIntent(captureIntent);
+
+ params.setRecordingHint(
+ captureIntent == CONTROL_CAPTURE_INTENT_VIDEO_RECORD ||
+ captureIntent == CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT);
+ }
+
// control.videoStabilizationMode
{
Integer stabMode = getIfSupported(request, CONTROL_VIDEO_STABILIZATION_MODE,
}
}
+ static int filterSupportedCaptureIntent(int captureIntent) {
+ switch (captureIntent) {
+ case CONTROL_CAPTURE_INTENT_CUSTOM:
+ case CONTROL_CAPTURE_INTENT_PREVIEW:
+ case CONTROL_CAPTURE_INTENT_STILL_CAPTURE:
+ case CONTROL_CAPTURE_INTENT_VIDEO_RECORD:
+ case CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT:
+ break;
+ case CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG:
+ case CONTROL_CAPTURE_INTENT_MANUAL:
+ captureIntent = CONTROL_CAPTURE_INTENT_PREVIEW;
+ Log.w(TAG, "Unsupported control.captureIntent value " + captureIntent
+ + "; default to PREVIEW");
+ default:
+ captureIntent = CONTROL_CAPTURE_INTENT_PREVIEW;
+ Log.w(TAG, "Unknown control.captureIntent value " + captureIntent
+ + "; default to PREVIEW");
+ }
+
+ return captureIntent;
+ }
+
private static List<Camera.Area> convertMeteringRegionsToLegacy(
Rect activeArray, ParameterUtils.ZoomData zoomData,
MeteringRectangle[] meteringRegions, int maxNumMeteringAreas, String regionName) {
mapAwb(result, /*out*/params);
/*
+ * control.captureIntent
+ */
+ {
+ int captureIntent = ParamsUtils.getOrDefault(request,
+ CaptureRequest.CONTROL_CAPTURE_INTENT,
+ /*defaultValue*/CaptureRequest.CONTROL_CAPTURE_INTENT_PREVIEW);
+
+ captureIntent = LegacyRequestMapper.filterSupportedCaptureIntent(captureIntent);
+
+ result.set(CONTROL_CAPTURE_INTENT, captureIntent);
+ }
+
+ /*
* control.mode
*/
{