gpt4 book ai didi

ios - 为什么 ARFaceAnchor 有负 Z 位置?

转载 作者:行者123 更新时间:2023-11-29 11:27:07 25 4
gpt4 key购买 nike

我正在使用 ARKit 的 ARFaceTrackingConfiguration ARConfiguration.WorldAlignment.camera 对齐,但我发现文档(表面上)并没有反射(reflect)现实;

根据下面的文档摘录,我预计面部 anchor 的 transform以右手坐标系表示。但是,当我尝试移动头部时,我注意到面部 anchor 的 Z 坐标始终为负(即 faceAnchor.transform.columns.3.z < 0 )。请注意,在 X 和 Y 方向上移动头部对应于预期结果(与 Z 坐标不同)。

Camera alignment defines a coordinate system based on the native sensor orientation of the device camera. Relative to a AVCaptureVideoOrientation.landscapeRight-oriented camera image, the x-axis points to the right, the y-axis points up, and the z-axis points out the front of the device (toward the user).

我想要 transform按照文档进行操作,即面部 anchor 的 Z 坐标应该是正的,因为文档说“z 轴指向设备的前面(朝向用户)”。到目前为止,Z 轴似乎指向设备的背面……

我是否漏掉了一些明显的东西?

我尝试通过以下代码修复旋转,但我不确定它是否是修复此问题的正确方法:

// Repair rotation
let oldFaceRotation = simd_quatf(face.transform) // get quaternion from
let repairedFaceRotation = simd_quatf(ix: oldFaceRotation.axis.y, iy: oldFaceRotation.axis.x, iz: -oldFaceRotation.axis.z, r: oldFaceRotation.real)

// Repair translation
var repairedPosition = face.transform.columns.3
repairedPosition.z *= -1

// Combine
var correctedFaceTransform = float4x4(repairedFaceRotation)
correctedFaceTransform.columns.3 = repairedPosition

最佳答案

看起来很明显:

当 ARSession 正在运行并且 ARCamera 开始跟踪环境时,它会将 WorldOriginAxis 放在你的脸前面 ( x: 0, y: 0, z: 0)。只需使用以下方法检查它:

 sceneView.debugOptions = [.showWorldOrigin]

所以你的脸的位置必须在世界坐标的 Z 轴的正向部分

enter image description here

Thus, ARFaceAnchor will be placed at positive Z-axis direction, as well.

enter image description here

当您使用 ARFaceTrackingConfigurationARWorldTrackingConfiguration 时,有两件事需要考虑:

  • 后置摄像头沿负 Z 轴(正 X 轴在右侧)移向物体。

  • 前置摄像头沿正 Z 轴(正 X 轴在左侧)朝向面部移动。

Hence, when you are "looking" through TrueDepth Camera, a 4x4 Matrix is mirrored.

关于ios - 为什么 ARFaceAnchor 有负 Z 位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57582930/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com