Android Utililty Methods Camera Orientation Check

List of utility methods to do Camera Orientation Check

Description

The list of methods to do Camera Orientation Check are organized into topic(s).

Method

intgetCameraOrientation(int cameraId)
get Camera Orientation
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
return info.orientation;
intgetDisplayOrientation(int degrees, int cameraId)
get Display Orientation
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId, info);
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
    result = (info.orientation + degrees) % 360;
    result = (360 - result) % 360; 
} else { 
    result = (info.orientation - degrees + 360) % 360;
...
intgetCameraDisplayOrientation(Context context, int cameraId, android.hardware.Camera camera)
get Camera Display Orientation
android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
int rotation = ((WindowManager) context
        .getSystemService(Context.WINDOW_SERVICE))
        .getDefaultDisplay().getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0:
...
intgetCameraPhotoOrientation(Context context, Uri imageUri, String imagePath)
Gets the camera photo orientation.
int rotate = 0;
context.getContentResolver().notifyChange(imageUri, null);
File imageFile = new File(imagePath);
ExifInterface exif = new android.media.ExifInterface(
        imageFile.getAbsolutePath());
int orientation = exif.getAttributeInt(
        ExifInterface.TAG_ORIENTATION,
        ExifInterface.ORIENTATION_NORMAL);
...