CtsVerifier: fix orientations in camera tests
Fix the jpeg orientation in the FOV calibration test and the video
orientation in the video test.
bug 17468230
Change-Id: If49f97f5e479c67c586c6ba3c61f5fa47bd370c3
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/fov/PhotoCaptureActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/fov/PhotoCaptureActivity.java
index eea1b76..e5af6ba 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/fov/PhotoCaptureActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/fov/PhotoCaptureActivity.java
@@ -77,6 +77,8 @@
private int mResolutionSpinnerIndex = -1;
private WakeLock mWakeLock;
private long shutterStartTime;
+ private int mPreviewOrientation;
+ private int mJpegOrientation;
private ArrayList<Integer> mPreviewSizeCamerasToProcess = new ArrayList<Integer>();
@@ -410,6 +412,8 @@
Toast.makeText(this, t.getMessage(), Toast.LENGTH_LONG).show();
return;
}
+
+ calculateOrientations(this, mSelectedResolution.cameraId, mCamera);
Camera.Parameters params = setCameraParams(mCamera);
// Either use chosen preview size for current camera or automatically
@@ -429,7 +433,7 @@
private void startPreview() {
if (mCameraInitialized && mCamera != null) {
- setCameraDisplayOrientation(this, mSelectedResolution.cameraId, mCamera);
+ mCamera.setDisplayOrientation(mPreviewOrientation);
mCamera.startPreview();
mPreviewActive = true;
}
@@ -479,6 +483,7 @@
Camera.Parameters params = camera.getParameters();
params.setJpegThumbnailSize(0, 0);
params.setJpegQuality(100);
+ params.setRotation(mJpegOrientation);
params.setFocusMode(getFocusMode(camera));
params.setZoom(0);
params.setPictureSize(mSelectedResolution.width, mSelectedResolution.height);
@@ -506,7 +511,7 @@
return result;
}
- public static void setCameraDisplayOrientation(Activity activity,
+ private void calculateOrientations(Activity activity,
int cameraId, android.hardware.Camera camera) {
android.hardware.Camera.CameraInfo info =
new android.hardware.Camera.CameraInfo();
@@ -521,13 +526,12 @@
case Surface.ROTATION_270: degrees = 270; break;
}
- int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
- result = (info.orientation + degrees) % 360;
- result = (360 - result) % 360; // compensate the mirror
+ mJpegOrientation = (info.orientation + degrees) % 360;
+ mPreviewOrientation = (360 - mJpegOrientation) % 360; // compensate the mirror
} else { // back-facing
- result = (info.orientation - degrees + 360) % 360;
+ mJpegOrientation = (info.orientation - degrees + 360) % 360;
+ mPreviewOrientation = mJpegOrientation;
}
- camera.setDisplayOrientation(result);
}
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/video/CameraVideoActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/video/CameraVideoActivity.java
index 97c0521..0a0e830 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/video/CameraVideoActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/video/CameraVideoActivity.java
@@ -70,6 +70,7 @@
private int mPreviewTexWidth;
private int mPreviewTexHeight;
private int mPreviewRotation;
+ private int mVideoRotation;
private VideoView mPlaybackView;
@@ -162,7 +163,10 @@
// Step 5: set preview output
// This is not necessary since preview has been taken care of
- // Step 6: prepare configured MediaRecorder
+ // Step 6: set orientation hint
+ mMediaRecorder.setOrientationHint(mVideoRotation);
+
+ // Step 7: prepare configured MediaRecorder
try {
mMediaRecorder.prepare();
} catch (IOException e) {
@@ -644,10 +648,11 @@
}
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
- mPreviewRotation = (info.orientation + degrees) % 360;
- mPreviewRotation = (360 - mPreviewRotation) % 360; // compensate the mirror
+ mVideoRotation = (info.orientation + degrees) % 360;
+ mPreviewRotation = (360 - mVideoRotation) % 360; // compensate the mirror
} else { // back-facing
- mPreviewRotation = (info.orientation - degrees + 360) % 360;
+ mVideoRotation = (info.orientation - degrees + 360) % 360;
+ mPreviewRotation = mVideoRotation;
}
if (mPreviewRotation != 0 && mPreviewRotation != 180) {
Log.w(TAG,