1.6 to 2.1 CameraInfo alternative?

耗尽温柔 提交于 2019-12-25 02:22:27

问题


android.Camera.Preferences.setRotation documentation

public void onOrientationChanged(int orientation) {     
    if (orientation == ORIENTATION_UNKNOWN) return;     
    android.hardware.Camera.CameraInfo info = 
        new android.hardware.Camera.CameraInfo();     
    android.hardware.Camera.getCameraInfo(cameraId, info);     
    orientation = (orientation + 45) / 90 * 90;     
    int rotation = 0;     
    if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {         
        rotation = (info.orientation - orientation + 360) % 360;     
    } else {  // back-facing camera         
        rotation = (info.orientation + orientation) % 360;     
    }     
    mParameters.setRotation(rotation); 
}

is there an alternative to Camera.CameraInfo in API level 5 (or better yet even 4)? I am trying to set the rotation of the captured image and I cannot figure out how to get the orientation of the device's camera. pre API level 9 was all camera's orientation fixed or something?


回答1:


No the camera orientation is at the current status a real mess on Android platform. Even the orientation you get with the camera info is not always the right one (at least for me) in my app i'm letting the user choose if he wants to rotate the camera with a parameter in the settings of the app



来源:https://stackoverflow.com/questions/5160660/1-6-to-2-1-camerainfo-alternative

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!