From 8b612081c091e6ffa8a20d334cbe788ca0928425 Mon Sep 17 00:00:00 2001 From: Jim Wilson Date: Mon, 23 Nov 2015 12:52:09 -0800 Subject: CameraNext: Update focus behavior for panoramas Panorama was using Infinity for the focus mode all the time for panoramas. Change to use continuous-picture in viewfinder before the actual mosaic is started then change to fixed to lock in. This allows indoor panoramas to not suck. Change-Id: Ida01ca1ded1e1058d76da851cd20e5b7072e15be (cherry picked from commit 33ece020c28796f004f28843fda28092e315c9dc) --- .../android/camera/WideAnglePanoramaModule.java | 37 +++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java index 424d8490d..d7a3d54d4 100644 --- a/src/com/android/camera/WideAnglePanoramaModule.java +++ b/src/com/android/camera/WideAnglePanoramaModule.java @@ -125,10 +125,6 @@ public class WideAnglePanoramaModule extends BaseModule imp private float mHorizontalViewAngle; private float mVerticalViewAngle; - // Prefer FOCUS_MODE_INFINITY to FOCUS_MODE_CONTINUOUS_VIDEO because of - // getting a better image quality by the former. - private String mTargetFocusMode = Parameters.FOCUS_MODE_INFINITY; - private PanoOrientationEventListener mOrientationEventListener; // The value could be 0, 90, 180, 270 for the 4 different orientations measured in clockwise // respectively. @@ -464,12 +460,13 @@ public class WideAnglePanoramaModule extends BaseModule imp parameters.setPreviewFpsRange(minFps, maxFps); Log.d(TAG, "preview fps: " + minFps + ", " + maxFps); + // use CAF for viewfinder until starting the real mosaic, then lock List supportedFocusModes = parameters.getSupportedFocusModes(); - if (supportedFocusModes.indexOf(mTargetFocusMode) >= 0) { - parameters.setFocusMode(mTargetFocusMode); + if (supportedFocusModes.indexOf(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) >= 0) { + parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); } else { // Use the default focus mode and log a message - Log.w(TAG, "Cannot set the focus mode to " + mTargetFocusMode + + Log.w(TAG, "Cannot set the focus mode to " + Parameters.FOCUS_MODE_CONTINUOUS_PICTURE + " becuase the mode is not supported."); } @@ -567,15 +564,25 @@ public class WideAnglePanoramaModule extends BaseModule imp public void startCapture() { // Reset values so we can do this again. + + Parameters parameters = mCameraDevice.getParameters(); + List supportedFocusModes = parameters.getSupportedFocusModes(); + if (supportedFocusModes.indexOf(Parameters.FOCUS_MODE_FIXED) >= 0) { + parameters.setFocusMode(Parameters.FOCUS_MODE_FIXED); + } else { + // Use the default focus mode and log a message + Log.w(TAG, "Cannot set the focus mode to " + Parameters.FOCUS_MODE_FIXED + + " becuase the mode is not supported."); + } + parameters.setAutoExposureLock(true); + parameters.setAutoWhiteBalanceLock(true); + configureCamera(parameters); + mCancelComputation = false; mTimeTaken = System.currentTimeMillis(); mActivity.setSwipingEnabled(false); mCaptureState = CAPTURE_STATE_MOSAIC; mUI.onStartCapture(); - Parameters parameters = mCameraDevice.getParameters(); - parameters.setAutoExposureLock(true); - parameters.setAutoWhiteBalanceLock(true); - configureCamera(parameters); final int sweepAngle = (mDeviceOrientation == 90 || mDeviceOrientation == 270) ? DEFAULT_SWEEP_ANGLE_LANDSCAPE : DEFAULT_SWEEP_ANGLE_PORTRAIT; @@ -627,6 +634,14 @@ public class WideAnglePanoramaModule extends BaseModule imp Parameters parameters = mCameraDevice.getParameters(); parameters.setAutoExposureLock(false); parameters.setAutoWhiteBalanceLock(false); + List supportedFocusModes = parameters.getSupportedFocusModes(); + if (supportedFocusModes.indexOf(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) >= 0) { + parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE); + } else { + // Use the default focus mode and log a message + Log.w(TAG, "Cannot set the focus mode to " + Parameters.FOCUS_MODE_CONTINUOUS_PICTURE + + " becuase the mode is not supported."); + } configureCamera(parameters); mMosaicFrameProcessor.setProgressListener(null); -- cgit v1.2.3