我想更好地理解 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 轴指向右侧”
:
这就是我描绘的方式“也就是说,x 轴始终指向设备的长轴,从前置摄像头指向主页按钮”
:
感谢任何帮助,谢谢!
更新:它不会影响这个问题,但为了更清楚,我问这个的原因是因为我有兴趣从 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 轴
Gravity and Heading
- y 轴将指向平行于重力
- z 轴将指向南方(-z 将指向真北)
- x 轴将指向东方
Camera
在这种情况下,相机将始终位于您的世界坐标空间中的 (0,0,0) y 轴将指向上方(如果您的手机处于纵向模式,则指向右侧),x 轴将从手机顶部指向主页按钮,而 z 轴将指向远离设备的方向
关于ios - ARKit 相机空间的方向是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59671828/