setDisplayOrientation()的Camera2 API等效项是什么? [英] What is the Camera2 API Equivalent of setDisplayOrientation()?

查看:646
本文介绍了setDisplayOrientation()的Camera2 API等效项是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用android.hardware.Camera,为了使摄像机输出正确跟踪设备的运动,我们需要将OrientationEventListener连接到Camera上的setDisplayOrientation()方法.这样,当用户扭转设备时,我们可以使相机预览中的正常显示"与现实世界中的正常显示"保持同步.对于围绕Y轴旋转设备(即从横向翻转为反向横向或向后翻转)尤其如此.

With android.hardware.Camera, in order to have the camera output appropriately track the device movement, we need to hook up an OrientationEventListener to the setDisplayOrientation() method on Camera. That way, as the user twists the device around, we can keep what is "up" on the camera preview in sync with what is "up" in the real world. This is particularly true for rotating the device around the Y axis (i.e., flipping from landscape to reverse-landscape or back).

对于大多数方向更改,android.hardware.camera2 API似乎正常".但是,对于该Y轴旋转(横向->反向横向,反之亦然),相机预览最终会被反转.

For most orientation changes, the android.hardware.camera2 API seems to "just work". However, for that Y-axis rotation (landscape -> reverse-landscape or vice versa), the camera preview winds up being inverted.

对于Camera2 API,在Camera上调用setDisplayOrientation()相当于什么,所以我们可以处理这种情况?

What is the equivalent of calling setDisplayOrientation() on Camera for the Camera2 API, so we can handle this scenario?

推荐答案

您已经注意到,这对于camera2 API上的SurfaceView应该是正常工作".

As you've noticed, this is supposed to "just work" for SurfaceView on the camera2 API.

因此,没有setDisplayOrientation()等效.

我们之前从未听说过此问题,因此有几个问题:

We haven't heard of this issue before now, so a few questions:

  1. 您是否已将应用锁定为横向模式,或者是否允许更改方向?
  2. 您是处理自己的方向更改,还是在方向更改时拆除框架并重新启动应用程序?
  3. 在发生180度旋转时,您是否会触发任何重新布局,例如调整快门按钮的位置?

这篇关于setDisplayOrientation()的Camera2 API等效项是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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