ios - ARKit 相机空间的方向是什么?

标签 ios swift transform augmented-reality arkit

我想更好地理解 ARKit 的 ARCamera 变换所在的相机坐标空间。In the documentation , 它说

This transform creates a local coordinate space for the camera that is constant with respect to device orientation. In camera space, the x-axis points to the right when the device is in UIDeviceOrientation.landscapeRight orientation—that is, the x-axis always points along the long axis of the device, from the front-facing camera toward the Home button. The y-axis points upward (with respect to UIDeviceOrientation.landscapeRight orientation), and the z-axis points away from the device on the screen side.

在此之后,the UIDeviceOrientation.landscapeRight documentation说:

The device is in landscape mode, with the device held upright and the home button on the left side.

当我试图理解这一点时,似乎“当设备处于 UIDeviceOrientation.landscapeRight 方向时 x 轴指向右侧”“之间存在冲突也就是说,x 轴始终指向设备的长轴,从前置摄像头指向主页按钮”。前者右边有+x,后者左边有+x。

这是我如何描绘“当设备处于 UIDeviceOrientation.landscapeRight 方向时 x 轴指向右侧”:

enter image description here

这就是我描绘的方式“也就是说,x 轴始终指向设备的长轴,从前置摄像头指向主页按钮”:

enter image description here

感谢任何帮助,谢谢!

更新:它不会影响这个问题,但为了更清楚,我问这个的原因是因为我有兴趣从 Core Location 获取 x、y 和 z 地磁数据值。 .在 Core Location 中,如果手机处于人像模式,+x 向右,+y 向上,+z 朝向用户。因此,ARKit 的相机坐标系似乎与 Core Location 中的相机坐标系不同。

最佳答案

让我们先解决一件事,landscapeRight 的主页按钮位于右侧,手机顶部位于左侧,这与您在图片中显示的截然不同。所以在你的图纸中,手机应该翻转 180 度。 landscapeRight 在这种情况下不同于设备方向

首先,Arkit session 的坐标系将取决于 world alignment setting of your AR session

所以你有三个选择

Gravity

  • 在这种情况下,无论设备的方向如何,Y 都会指向上方,与重力平行

For the z-axis, ARKit chooses a basis vector (0,0,-1) pointing in the direction the device camera faces and perpendicular to the gravity axis

  • 据此,z 轴将指向摄像头朝向的方向(因此对于前置摄像头,z 轴将指向屏幕,而对于后置摄像头,z 轴将指向电话并远离你)

  • 然后用右手定则确定 X 轴

enter image description here

Gravity and Heading

  • y 轴将指向平行于重力
  • z 轴将指向南方(-z 将指向真北)
  • x 轴将指向东方

enter image description here

Camera

在这种情况下,相机将始终位于您的世界坐标空间中的 (0,0,0) y 轴将指向上方(如果您的手机处于纵向模式,则指向右侧),x 轴将从手机顶部指向主页按钮,而 z 轴将指向远离设备的方向

关于ios - ARKit 相机空间的方向是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59671828/

相关文章:

ios - SwiftUI 的 onAppear() 和 onDisappear() 在 Xcode 12.1 上多次调用且不一致

ios - 如何使用 UIImageView 和 UICollectionView 创建布局以及 Collection View 在滚动时更改高度?

c# - 逆变换点如何工作?统一C#

python - 在Python中,如何进行groupby+transform+设计的函数来移动一列中的值?

objective-c - 检测设备上的 iTunes 播放列表文件夹

ios - Xcode内置png压缩效果

swift - 使用 Swift 将字符串分成两半(Word-Aware)

ios - 在 Storyboard中使用 Xib 时,Xib 的 IBOutlets 返回 nil

css - 在使用 border-radius 创建的圆圈内垂直居中文本

ios - 如何禁用 Firebase 电话身份验证的限制?