简体   繁体   English

1.6到2.1 CameraInfo的替代品?

[英]1.6 to 2.1 CameraInfo alternative?

android.Camera.Preferences.setRotation documentation android.Camera.Preferences.setRotation文档

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)? 在API级别5(甚至更好甚至4)中,Camera.CameraInfo是否可以替代? 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? API等级9之前的版本是否固定了所有相机的方向?

No the camera orientation is at the current status a real mess on Android platform. 在当前状态下,没有任何相机方向在Android平台上是真正的混乱。 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 即使在我的应用程序中,即使使用相机信息获得的方向也不总是正确的方向(至少对我而言),我让用户选择是否要使用应用程序设置中的参数旋转相机

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM