@Test public void cameraInfo_canReturnSensorOrientation() throws CameraInfoUnavailableException { CameraInfo cameraInfo = new Camera2CameraInfo(mCameraManager, CAMERA0_ID); assertThat(cameraInfo.getSensorRotationDegrees()).isEqualTo(CAMERA0_SENSOR_ORIENTATION); }
@Override public int getSensorRotationDegrees(@RotationValue int relativeRotation) { Integer sensorOrientation = mCameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); Preconditions.checkNotNull(sensorOrientation); int relativeRotationDegrees = CameraOrientationUtil.surfaceRotationToDegrees(relativeRotation); boolean isOppositeFacingScreen = LensFacing.BACK.equals(getLensFacing()); return CameraOrientationUtil.getRelativeImageRotation( relativeRotationDegrees, sensorOrientation, isOppositeFacingScreen); }
Camera2CameraInfo implements CameraInfo { @Override public int getSensorRotationDegrees(@RotationValue int relativeRotation) { Integer sensorOrientation = mCameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); Preconditions.checkNotNull(sensorOrientation); int relativeRotationDegrees = CameraOrientationUtil.surfaceRotationToDegrees(relativeRotation); boolean isOppositeFacingScreen = LensFacing.BACK.equals(getLensFacing()); return CameraOrientationUtil.getRelativeImageRotation( relativeRotationDegrees, sensorOrientation, isOppositeFacingScreen); } }
Camera2CameraInfo implements CameraInfo { @Override public int getSensorRotationDegrees(@RotationValue int relativeRotation) { Integer sensorOrientation = mCameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); Preconditions.checkNotNull(sensorOrientation); int relativeRotationDegrees = CameraOrientationUtil.surfaceRotationToDegrees(relativeRotation); boolean isOppositeFacingScreen = LensFacing.BACK.equals(getLensFacing()); return CameraOrientationUtil.getRelativeImageRotation( relativeRotationDegrees, sensorOrientation, isOppositeFacingScreen); } Camera2CameraInfo(CameraManager cameraManager, String cameraId); }
Camera2CameraInfo implements CameraInfo { @Override public int getSensorRotationDegrees(@RotationValue int relativeRotation) { Integer sensorOrientation = mCameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); Preconditions.checkNotNull(sensorOrientation); int relativeRotationDegrees = CameraOrientationUtil.surfaceRotationToDegrees(relativeRotation); boolean isOppositeFacingScreen = LensFacing.BACK.equals(getLensFacing()); return CameraOrientationUtil.getRelativeImageRotation( relativeRotationDegrees, sensorOrientation, isOppositeFacingScreen); } Camera2CameraInfo(CameraManager cameraManager, String cameraId); @Nullable @Override LensFacing getLensFacing(); @Override int getSensorRotationDegrees(@RotationValue int relativeRotation); @Override int getSensorRotationDegrees(); }
Camera2CameraInfo implements CameraInfo { @Override public int getSensorRotationDegrees(@RotationValue int relativeRotation) { Integer sensorOrientation = mCameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION); Preconditions.checkNotNull(sensorOrientation); int relativeRotationDegrees = CameraOrientationUtil.surfaceRotationToDegrees(relativeRotation); boolean isOppositeFacingScreen = LensFacing.BACK.equals(getLensFacing()); return CameraOrientationUtil.getRelativeImageRotation( relativeRotationDegrees, sensorOrientation, isOppositeFacingScreen); } Camera2CameraInfo(CameraManager cameraManager, String cameraId); @Nullable @Override LensFacing getLensFacing(); @Override int getSensorRotationDegrees(@RotationValue int relativeRotation); @Override int getSensorRotationDegrees();  }