public static int getJpegRotation(int cameraId, int orientation) {
// See android.hardware.Camera.Parameters.setRotation for
// documentation.
int rotation = 0;
if (orientation != OrientationEventListener.ORIENTATION_UNKNOWN) {
CameraInfo info = CameraHolder.instance().getCameraInfo()[cameraId];
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (info.orientation - orientation + 360) % 360;
} else { // back-facing camera
rotation = (info.orientation + orientation) % 360;
}
}// +{
else if(orientation == OrientationEventListener.ORIENTATION_UNKNOWN) {
// If no orientation sensor exists, the jpg rotation needs to be modified
Log.d(TAG, "getJpegRotation: no orientation sensor data received");
int baseOrientation = SystemProperties.getInt("ro.cam.jpg.ori.base", 0);
CameraInfo info = CameraHolder.instance().getCameraInfo()[cameraId];
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (info.orientation - baseOrientation + 360) % 360;
} else { // back-facing camera
rotation = (info.orientation + baseOrientation) % 360;
}
Log.d(TAG, "getJpegRotation: new rotation = " + rotation);
}
// +}
return rotation;
}
相機應用在沒有傳感器提供方向數據時,照片方向計算錯誤
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.