Fix exif orientation for facing camera

pull/1/head
Mattia Iavarone 7 years ago
parent 2c0bc641eb
commit 4f554a5184
  1. 17
      camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java

@ -368,16 +368,15 @@ class Camera1 extends CameraImpl {
// Set boolean to wait for image callback // Set boolean to wait for image callback
mIsCapturingImage = true; mIsCapturingImage = true;
final int exifRotation = computeExifRotation();
final boolean exifFlip = computeExifFlip();
final int sensorToDisplay = computeSensorToDisplayOffset();
synchronized (mLock) { synchronized (mLock) {
Camera.Parameters parameters = mCamera.getParameters(); Camera.Parameters parameters = mCamera.getParameters();
int rotation = computeExifRotation(); Log.e(TAG, "Setting exif rotation to "+exifRotation);
Log.e(TAG, "Setting exif rotation to "+rotation); parameters.setRotation(exifRotation);
parameters.setRotation(rotation);
mCamera.setParameters(parameters); mCamera.setParameters(parameters);
} }
final int exifRotation = computeExifRotation();
final boolean exifFlip = computeExifFlip();
final int sensorToDisplay = computeSensorToDisplayOffset();
// Is the final picture (decoded respecting EXIF) consistent with CameraView orientation? // Is the final picture (decoded respecting EXIF) consistent with CameraView orientation?
// We must consider exifOrientation to bring back the picture in the sensor world. // We must consider exifOrientation to bring back the picture in the sensor world.
// Then use sensorToDisplay to move to the display world, where CameraView lives. // Then use sensorToDisplay to move to the display world, where CameraView lives.
@ -479,7 +478,11 @@ class Camera1 extends CameraImpl {
* This ignores flipping for facing camera. * This ignores flipping for facing camera.
*/ */
private int computeExifRotation() { private int computeExifRotation() {
return (mDeviceOrientation + mSensorOffset) % 360; if (mFacing == CameraKit.Constants.FACING_FRONT) {
return (mSensorOffset - mDeviceOrientation + 360) % 360;
} else {
return (mSensorOffset + mDeviceOrientation) % 360;
}
} }

Loading…
Cancel
Save