1.6至2.1 CameraInfo选择? [英] 1.6 to 2.1 CameraInfo alternative?

查看:273
本文介绍了1.6至2.1 CameraInfo选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<一个href=\"http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setRotation%28int%29\"相对=nofollow称号=机器人的摄像头。preferences.setRotation文件> 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); 
}

有没有在API级别5 Camera.CameraInfo替代(或更好,但即使4)?我想设置拍摄图像的旋转,我无法弄清楚如何获得设备的摄像头的方向。 pre API 9级是所有相机的方位固定的东西?

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?

推荐答案

没有摄像头的方向是在目前的状况对Android平台的一个真正的混乱。
即使你用相机信息获得的方向并不总是正确的(至少我)在我的应用我让,如果他想在应用程序的设置参数旋转摄像机的用户选择。

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

这篇关于1.6至2.1 CameraInfo选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆