|
发表于 2020-8-4 20:13:55
7988 浏览 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;
}
|
|
|
|
|
|
|
登录或注册
|