相关疑难解决方法(0)

Android的CameraInfo.orientation是否正确记录?错误地实施了?

在Android中,您可以Camera通过检索a来获取a 的属性的描述CameraInfo.我对方向很感兴趣,如http://developer.android.com/reference/android/hardware/Camera.CameraInfo.html#orientation所述.

然而,文档似乎与我的所有四个设备的行为方式不一致,而且,我有第五个设备的消息,这个设备看起来固定不变.

特别是,文档说:

该值是摄像机图像需要顺时针旋转的角度,因此它在显示屏上以其自然方向正确显示....例如,假设设备具有自然高的屏幕.后置摄像头传感器安装在横向上.你在看屏幕.如果相机传感器的顶部以自然方向与屏幕的右边缘对齐,则值应为90.如果前置摄像头传感器的顶部与屏幕右侧对齐,则值应为是270.

但在所述示例中,相机图像相对于自然高的方向顺时针旋转90度,而不是相反.也就是说,顶部与设备右侧对齐的图像需要顺时针旋转270度才能与设备的顶部对齐.

至少,我的所有四个设备都会为此值报告"90",并且当保持在自然方向时,所有设备的行为都好像相机的顶部是设备的右侧.也就是说,图像必须顺时针旋转270度,而不是90度,以匹配自然方向.这个例子似乎是对的; 第一行没有.

这个示例代码似乎支持我的结论,因为它只在方向被解释为上面时才给出正确的结果.

奇怪的是,我有来自一个用户设备的记录证据,显示它有时报告该值为90,其他时间报告为0!它应该是相机如何坐在设备中的物理属性,对吧?

  1. 任何人都可以确认文档的第一行实际上是错误的,这个例子是对的吗?
  2. 有没有人观察到价值的变化CameraInfo.orientation?在文档中是否有证据证明这是合法行为,或者它可能是设备中的错误?
  3. 任何其他相关的评论,经验,陷阱我还没有遇到过?

camera android orientation

24
推荐指数
2
解决办法
1万
查看次数

setDisplayOrientation示例代码是否正确?

Camera.setDisplayOrientation 的文档页面包含以下代码示例,声明使用它将"使摄像机图像以与显示相同的方向显示":

 public static void setCameraDisplayOrientation(Activity activity,
         int cameraId, android.hardware.Camera camera) {
     android.hardware.Camera.CameraInfo info =
             new android.hardware.Camera.CameraInfo();
     android.hardware.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: degrees = 90; break;
         case Surface.ROTATION_180: degrees = 180; break;
         case Surface.ROTATION_270: degrees = 270; break;
     }

     int result;
     if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
         result = (info.orientation + degrees) % 360;
         result = (360 - result) % 360;  // …
Run Code Online (Sandbox Code Playgroud)

android screen-orientation android-camera

17
推荐指数
1
解决办法
6109
查看次数