diff options
author | Wei Huang <weih@google.com> | 2011-10-18 05:53:01 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-10-18 05:53:01 -0700 |
commit | 046b8ced839d1b04c32d1207fe53f7639d69453b (patch) | |
tree | a6da96986e3a9d2bb7c09fafedd54f0d99e9fdac /src | |
parent | 136c335a69069bbb07af1a842acc4629c3131139 (diff) | |
parent | d991766dc3bcc03a02c6648e2cfd54ee4f8cbd9e (diff) | |
download | LegacyCamera-046b8ced839d1b04c32d1207fe53f7639d69453b.zip LegacyCamera-046b8ced839d1b04c32d1207fe53f7639d69453b.tar.gz LegacyCamera-046b8ced839d1b04c32d1207fe53f7639d69453b.tar.bz2 |
Merge "Use calculated frame offset instead of gyroscope." into ics-mr0
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/panorama/MosaicFrameProcessor.java | 29 | ||||
-rwxr-xr-x | src/com/android/camera/panorama/PanoramaActivity.java | 68 |
2 files changed, 22 insertions, 75 deletions
diff --git a/src/com/android/camera/panorama/MosaicFrameProcessor.java b/src/com/android/camera/panorama/MosaicFrameProcessor.java index 7660f5e..300e4e3 100644 --- a/src/com/android/camera/panorama/MosaicFrameProcessor.java +++ b/src/com/android/camera/panorama/MosaicFrameProcessor.java @@ -65,7 +65,8 @@ public class MosaicFrameProcessor { private int mPreviewBufferSize; public interface ProgressListener { - public void onProgress(boolean isFinished, float panningRateX, float panningRateY); + public void onProgress(boolean isFinished, float panningRateX, float panningRateY, + float progressX, float progressY); } public MosaicFrameProcessor(int previewWidth, int previewHeight, int bufSize) { @@ -173,11 +174,15 @@ public class MosaicFrameProcessor { // Publish progress of the ongoing processing if (mProgressListener != null) { - mProgressListener.onProgress(false, mPanningRateX, mPanningRateY); + mProgressListener.onProgress(false, mPanningRateX, mPanningRateY, + mTranslationLastX * HR_TO_LR_DOWNSAMPLE_FACTOR / mPreviewWidth, + mTranslationLastY * HR_TO_LR_DOWNSAMPLE_FACTOR / mPreviewHeight); } } else { if (mProgressListener != null) { - mProgressListener.onProgress(true, mPanningRateX, mPanningRateY); + mProgressListener.onProgress(true, mPanningRateX, mPanningRateY, + mTranslationLastX * HR_TO_LR_DOWNSAMPLE_FACTOR / mPreviewWidth, + mTranslationLastY * HR_TO_LR_DOWNSAMPLE_FACTOR / mPreviewHeight); } } } @@ -211,20 +216,20 @@ public class MosaicFrameProcessor { mTotalTranslationY += mDeltaY[idx]; mTotalDeltaTime += mDeltaTime[idx]; - mTranslationLastX = translationCurrX; - mTranslationLastY = translationCurrY; - mLastProcessedFrameTimestamp = now; - mOldestIdx = (mOldestIdx + 1) % WINDOW_SIZE; - // The panning rate is measured as the rate of the translation percentage in // image width/height. Take the horizontal panning rate for example, the image width // used in finding the translation is (PreviewWidth / HR_TO_LR_DOWNSAMPLE_FACTOR). // To get the horizontal translation percentage, the horizontal translation, // (translationCurrX - mTranslationLastX), is divided by the // image width. We then get the rate by dividing the translation percentage with deltaTime. - mPanningRateX = mTotalTranslationX / (mPreviewWidth / HR_TO_LR_DOWNSAMPLE_FACTOR) - / mTotalDeltaTime; - mPanningRateY = mTotalTranslationY / (mPreviewHeight / HR_TO_LR_DOWNSAMPLE_FACTOR) - / mTotalDeltaTime; + mPanningRateX = mTotalTranslationX / + (mPreviewWidth / HR_TO_LR_DOWNSAMPLE_FACTOR) / mTotalDeltaTime; + mPanningRateY = mTotalTranslationY / + (mPreviewHeight / HR_TO_LR_DOWNSAMPLE_FACTOR) / mTotalDeltaTime; + + mTranslationLastX = translationCurrX; + mTranslationLastY = translationCurrY; + mLastProcessedFrameTimestamp = now; + mOldestIdx = (mOldestIdx + 1) % WINDOW_SIZE; } } diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java index f11bc3a..bbd45b8 100755 --- a/src/com/android/camera/panorama/PanoramaActivity.java +++ b/src/com/android/camera/panorama/PanoramaActivity.java @@ -49,8 +49,6 @@ import android.hardware.Camera; import android.hardware.Camera.Parameters; import android.hardware.Camera.Size; import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.net.Uri; import android.os.Bundle; @@ -554,13 +552,14 @@ public class PanoramaActivity extends ActivityBase implements mMosaicFrameProcessor.setProgressListener(new MosaicFrameProcessor.ProgressListener() { @Override - public void onProgress(boolean isFinished, float panningRateX, float panningRateY) { + public void onProgress(boolean isFinished, float panningRateX, float panningRateY, + float progressX, float progressY) { if (isFinished || (mMaxAngleX - mMinAngleX >= DEFAULT_SWEEP_ANGLE) || (mMaxAngleY - mMinAngleY >= DEFAULT_SWEEP_ANGLE)) { stopCapture(false); } else { - updateProgress(panningRateX); + updateProgress(panningRateX, progressX, progressY); } } }); @@ -625,7 +624,7 @@ public class PanoramaActivity extends ActivityBase implements mRightIndicator.setEnabled(false); } - private void updateProgress(float panningRate) { + private void updateProgress(float panningRate, float progressX, float progressY) { mMosaicView.setReady(); mMosaicView.requestRender(); @@ -637,6 +636,7 @@ public class PanoramaActivity extends ActivityBase implements } else { hideTooFastIndication(); } + mPanoProgressBar.setProgress((int) (progressX * mHorizontalViewAngle)); } private void createContentView() { @@ -909,7 +909,6 @@ public class PanoramaActivity extends ActivityBase implements releaseCamera(); mMosaicView.onPause(); clearMosaicFrameProcessorIfNeeded(); - mSensorManager.unregisterListener(mListener); mOrientationEventListener.disable(); System.gc(); } @@ -920,14 +919,6 @@ public class PanoramaActivity extends ActivityBase implements mPausing = false; mOrientationEventListener.enable(); - /* - * It is not necessary to get accelerometer events at a very high rate, - * by using a game rate (SENSOR_DELAY_UI), we get an automatic - * low-pass filter, which "extracts" the gravity component of the - * acceleration. As an added benefit, we use less power and CPU - * resources. - */ - mSensorManager.registerListener(mListener, mSensor, SensorManager.SENSOR_DELAY_UI); mCaptureState = CAPTURE_STATE_VIEWFINDER; setupCamera(); @@ -938,55 +929,6 @@ public class PanoramaActivity extends ActivityBase implements mMosaicView.onResume(); } - private void updateCompassValue() { - if (mCaptureState == CAPTURE_STATE_VIEWFINDER) return; - // By what angle has the camera moved since start of capture? - mTraversedAngleX = (int) (mCompassValueX - mCompassValueXStart); - mTraversedAngleY = (int) (mCompassValueY - mCompassValueYStart); - mMinAngleX = Math.min(mMinAngleX, mTraversedAngleX); - mMaxAngleX = Math.max(mMaxAngleX, mTraversedAngleX); - mMinAngleY = Math.min(mMinAngleY, mTraversedAngleY); - mMaxAngleY = Math.max(mMaxAngleY, mTraversedAngleY); - - // Use orientation to identify if the user is panning to the right or the left. - switch (mDeviceOrientation) { - case 0: - mPanoProgressBar.setProgress(-mTraversedAngleX); - break; - case 90: - mPanoProgressBar.setProgress(mTraversedAngleY); - break; - case 180: - mPanoProgressBar.setProgress(mTraversedAngleX); - break; - case 270: - mPanoProgressBar.setProgress(-mTraversedAngleY); - break; - } - mPanoProgressBar.invalidate(); - } - - private final SensorEventListener mListener = new SensorEventListener() { - public void onSensorChanged(SensorEvent event) { - if (event.sensor.getType() == Sensor.TYPE_GYROSCOPE) { - if (mTimestamp != 0) { - final float dT = (event.timestamp - mTimestamp) * NS2S; - mCompassValueX += event.values[1] * dT * 180.0f / Math.PI; - mCompassValueY += event.values[0] * dT * 180.0f / Math.PI; - mCompassValueXStartBuffer = mCompassValueX; - mCompassValueYStartBuffer = mCompassValueY; - updateCompassValue(); - } - mTimestamp = event.timestamp; - - } - } - - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - }; - public MosaicJpeg generateFinalMosaic(boolean highRes) { if (mMosaicFrameProcessor.createMosaic(highRes) == Mosaic.MOSAIC_RET_CANCELLED) { return null; |