Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(cameraId,info);
//获得旋转角度
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0: //没有旋转
degrees = 0;
break;
case Surface.ROTATION_90: //旋转90°
degrees = 90;
break;
case Surface.ROTATION_180: //180
degrees = 180;
break;
case Surface.ROTATION_270:
degrees = 270;
break;
}
int result = 0;
if(info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT){
//前置摄像头旋转算法
result = (info.orientation + degrees) % 360;
result = (360 - result) % 360;
}else{
result = (info.orientation - degrees + 360) % 360;
}
ROTATE = result + 180;
camera.setDi