summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ta Chen <weita@google.com>2011-08-18 17:17:26 -0700
committerWei-Ta Chen <weita@google.com>2011-08-19 14:29:27 -0700
commit43b0b2ccd5949ee8fc377c37e7e2b82a26c88ca8 (patch)
tree620723ba66ac19286ebac0de48ef168ab5cc7f72
parent1b55a6b36019929e0dca5edec5cfc44316b93f3d (diff)
downloadLegacyCamera-43b0b2ccd5949ee8fc377c37e7e2b82a26c88ca8.zip
LegacyCamera-43b0b2ccd5949ee8fc377c37e7e2b82a26c88ca8.tar.gz
LegacyCamera-43b0b2ccd5949ee8fc377c37e7e2b82a26c88ca8.tar.bz2
Set a panning speed threshold across all devices.
We set the threshold to 30 degrees/sec. Bug: 5182333 Change-Id: I29282893519f54601738b74945b2146c016c0af3
-rw-r--r--src/com/android/camera/panorama/MosaicFrameProcessor.java26
-rw-r--r--src/com/android/camera/panorama/PanoramaActivity.java23
2 files changed, 38 insertions, 11 deletions
diff --git a/src/com/android/camera/panorama/MosaicFrameProcessor.java b/src/com/android/camera/panorama/MosaicFrameProcessor.java
index f3c3201..bc7a5a2 100644
--- a/src/com/android/camera/panorama/MosaicFrameProcessor.java
+++ b/src/com/android/camera/panorama/MosaicFrameProcessor.java
@@ -29,6 +29,7 @@ public class MosaicFrameProcessor {
private static final int FRAME_COUNT_INDEX = 9;
private static final int X_COORD_INDEX = 2;
private static final int Y_COORD_INDEX = 5;
+ private static final int HR_TO_LR_DOWNSAMPLE_FACTOR = 4;
private Mosaic mMosaicer;
private boolean mIsMosaicMemoryAllocated = false;
@@ -51,14 +52,17 @@ public class MosaicFrameProcessor {
private int mCompassThreshold;
private int mTraversedAngleX;
private int mTraversedAngleY;
- private float mTranslationRate;
+
+ // Panning rate is in unit of percentage of image content translation / second.
+ private float mPanningRateX;
+ private float mPanningRateY;
private int mPreviewWidth;
private int mPreviewHeight;
private int mPreviewBufferSize;
public interface ProgressListener {
- public void onProgress(boolean isFinished, float translationRate,
+ public void onProgress(boolean isFinished, float panningRateX, float panningRateY,
int traversedAngleX, int traversedAngleY);
}
@@ -161,12 +165,12 @@ public class MosaicFrameProcessor {
// Publish progress of the ongoing processing
if (mProgressListener != null) {
- mProgressListener.onProgress(false, mTranslationRate,
+ mProgressListener.onProgress(false, mPanningRateX, mPanningRateY,
mTraversedAngleX, mTraversedAngleY);
}
} else {
if (mProgressListener != null) {
- mProgressListener.onProgress(true, mTranslationRate,
+ mProgressListener.onProgress(true, mPanningRateX, mPanningRateY,
mTraversedAngleX, mTraversedAngleY);
}
}
@@ -181,8 +185,18 @@ public class MosaicFrameProcessor {
mTotalFrameCount = (int) frameData[FRAME_COUNT_INDEX];
float translationCurrX = frameData[X_COORD_INDEX];
float translationCurrY = frameData[Y_COORD_INDEX];
- mTranslationRate = Math.max(Math.abs(translationCurrX - mTranslationLastX),
- Math.abs(translationCurrY - mTranslationLastY)) / deltaTime;
+
+ // 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 = Math.abs(translationCurrX - mTranslationLastX)
+ / (mPreviewWidth / HR_TO_LR_DOWNSAMPLE_FACTOR) / deltaTime;
+ mPanningRateY = Math.abs(translationCurrY - mTranslationLastY)
+ / (mPreviewHeight / HR_TO_LR_DOWNSAMPLE_FACTOR) / deltaTime;
+
mTranslationLastX = translationCurrX;
mTranslationLastY = translationCurrY;
}
diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java
index e507e06..facf7d9 100644
--- a/src/com/android/camera/panorama/PanoramaActivity.java
+++ b/src/com/android/camera/panorama/PanoramaActivity.java
@@ -74,6 +74,9 @@ public class PanoramaActivity extends Activity implements
private static final int CAPTURE_VIEWFINDER = 0;
private static final int CAPTURE_MOSAIC = 1;
+ // Speed is in unit of deg/sec
+ private static final float PANNING_SPEED_THRESHOLD = 30f;
+
// Ratio of nanosecond to second
private static final float NS2S = 1.0f / 1000000000.0f;
@@ -103,6 +106,8 @@ public class PanoramaActivity extends Activity implements
private SurfaceTexture mSurfaceTexture;
private boolean mThreadRunning;
private float[] mTransformMatrix;
+ private float mHorizontalViewAngle;
+ private float mVerticalViewAngle;
@Override
public void onCreate(Bundle icicle) {
@@ -213,6 +218,9 @@ public class PanoramaActivity extends Activity implements
Log.v(TAG, "preview fps: " + minFps + ", " + maxFps);
parameters.setRecordingHint(false);
+
+ mHorizontalViewAngle = parameters.getHorizontalViewAngle();
+ mVerticalViewAngle = parameters.getVerticalViewAngle();
}
public int getPreviewBufSize() {
@@ -314,12 +322,12 @@ public class PanoramaActivity extends Activity implements
mMosaicFrameProcessor.setProgressListener(new MosaicFrameProcessor.ProgressListener() {
@Override
- public void onProgress(boolean isFinished, float translationRate, int traversedAngleX,
- int traversedAngleY) {
+ public void onProgress(boolean isFinished, float panningRateX, float panningRateY,
+ int traversedAngleX, int traversedAngleY) {
if (isFinished) {
stopCapture();
} else {
- updateProgress(translationRate, traversedAngleX, traversedAngleY);
+ updateProgress(panningRateX, panningRateY, traversedAngleX, traversedAngleY);
}
}
});
@@ -358,12 +366,17 @@ public class PanoramaActivity extends Activity implements
}
}
- private void updateProgress(float translationRate, int traversedAngleX, int traversedAngleY) {
+ private void updateProgress(float panningRateX, float panningRateY,
+ int traversedAngleX, int traversedAngleY) {
mMosaicView.setReady();
mMosaicView.requestRender();
- if (translationRate > 150) {
+ // TODO: Now we just display warning message by the panning speed.
+ // Since we only support horizontal panning, we should display a warning message
+ // in UI when there're significant vertical movements.
+ if ((panningRateX * mHorizontalViewAngle > PANNING_SPEED_THRESHOLD)
+ || (panningRateY * mVerticalViewAngle > PANNING_SPEED_THRESHOLD)) {
// TODO: draw speed indication according to the UI spec.
mTooFastPrompt.setVisibility(View.VISIBLE);
mCaptureView.setSweepAngle(Math.max(traversedAngleX, traversedAngleY) + 1);