What is the Camera2 API Equivalent of setDisplayOrientation()?

后端 未结 4 1901
走了就别回头了
走了就别回头了 2020-12-24 12:35

With android.hardware.Camera, in order to have the camera output appropriately track the device movement, we need to hook up an OrientationEventListener

4条回答
  •  北海茫月
    2020-12-24 13:28

    use the formula below to get device rotation.

    private int getOrientation(int rotation) {
        return (ORIENTATIONS.get(rotation) + mSensorOrientation + 270) % 360;
    }
    

    SensorOrientation is a field assigned from

    characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION) 
    

    Solution suggested by google engineer: yaraki

    https://github.com/googlesamples/android-Camera2Basic/issues/24

提交回复
热议问题