搜索

232

主题

273

帖子

1916

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1916
发表于 2020-8-4 20:13:55 4970 浏览 0 回复

android9.0 camera 预览方向与拍照方向不一致

--- a/vendor/mediatek/proprietary/packages/apps/Camera2/common/src/com/mediatek/camera/common/utils/CameraUtil.java
+++ b/vendor/mediatek/proprietary/packages/apps/Camera2/common/src/com/mediatek/camera/common/utils/CameraUtil.java
@@ -229,11 +229,16 @@ public final class CameraUtil {
         int facing = characteristics.get(CameraCharacteristics.LENS_FACING);
         int sensorOrientation = characteristics
                 .get(CameraCharacteristics.SENSOR_ORIENTATION);
-        if (facing == CameraMetadata.LENS_FACING_FRONT) {
-            result = (sensorOrientation - orientation + 360) % 360;
-        } else {
-            result = (sensorOrientation + orientation) % 360;
-        }
+               
+               if (orientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
+               if (facing == CameraMetadata.LENS_FACING_FRONT) {
+               result = (sensorOrientation - orientation + 360) % 360;
+               } else {
+               result = (sensorOrientation + orientation) % 360;
+               }
+               }else{
+                  result = orientation;
+               }
         return result;
     }

@@ -1041,11 +1046,17 @@ public final class CameraUtil {
         int facing = characteristics.get(CameraCharacteristics.LENS_FACING);
         int orientation = characteristics
                 .get(CameraCharacteristics.SENSOR_ORIENTATION);
+               
+               if (sensorOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
         if (facing == CameraMetadata.LENS_FACING_FRONT) {
             result = (orientation - sensorOrientation + 360) % 360;
-        } else {
+          } else {
             result = (orientation + sensorOrientation) % 360;
-        }
+          }
+                 
+               }else{
+                    result = orientation;
+               }
         return result;
     }


回复

使用道具 举报

返回列表
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


登录或注册
快速回复 返回顶部 返回列表