1 package com.introlab.rtabmap;
19 import android.app.Activity;
20 import android.content.Context;
21 import android.hardware.camera2.CameraAccessException;
22 import android.hardware.camera2.CameraCharacteristics;
23 import android.hardware.camera2.CameraManager;
24 import android.hardware.display.DisplayManager;
25 import android.hardware.display.DisplayManager.DisplayListener;
26 import android.view.Display;
27 import android.view.Surface;
28 import android.view.WindowManager;
29 import com.google.ar.core.Session;
50 displayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
51 cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
52 WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
53 display = windowManager.getDefaultDisplay();
91 int displayRotation =
display.getRotation();
104 switch (cameraSensorToDisplayRotation) {
114 throw new RuntimeException(
"Unhandled rotation: " + cameraSensorToDisplayRotation);
124 CameraCharacteristics characteristics;
126 characteristics =
cameraManager.getCameraCharacteristics(cameraId);
127 }
catch (CameraAccessException
e) {
128 throw new RuntimeException(
"Unable to determine display orientation",
e);
132 int sensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
138 return (sensorOrientation - displayOrientation + 360) % 360;
143 case Surface.ROTATION_0:
145 case Surface.ROTATION_90:
147 case Surface.ROTATION_180:
149 case Surface.ROTATION_270:
152 throw new RuntimeException(
"Unknown rotation " +
rotation);