ios - 为什么我们在 Apple 的“使用场景深度可视化点云”示例代码中需要“rotateToARCamera”?
问题描述
示例代码:https ://developer.apple.com/documentation/arkit/visualizing_a_point_cloud_using_scene_depth
在代码中,当将深度图非投影到世界点时,我们使用正 z 值(深度值)。但据我了解,ARKit 使用右手坐标系,这意味着 z 值为正的点位于相机后面。所以也许我们需要做一些额外的工作来对齐坐标系(使用rotateToARCamera
矩阵?)。但我不明白为什么我们需要翻转 Y 和 Z 平面。
static func makeRotateToARCameraMatrix(orientation: UIInterfaceOrientation) -> matrix_float4x4 {
// flip to ARKit Camera's coordinate
let flipYZ = matrix_float4x4(
[1, 0, 0, 0],
[0, -1, 0, 0],
[0, 0, -1, 0],
[0, 0, 0, 1] )
let rotationAngle = Float(cameraToDisplayRotation(orientation: orientation)) * .degreesToRadian
return flipYZ * matrix_float4x4(simd_quaternion(rotationAngle, Float3(0, 0, 1)))
}
更新:我猜关键点是用于相机内在矩阵的针孔模型的坐标系与 ARKit 中的正常相机空间相比具有相反的方向。
解决方案
Depth Map 是像图像数据一样,Y 坐标在顶部较小而在底部较大的坐标系,但 ARKit 是 Y 坐标从底部较小而在顶部较大的坐标系。
出于这个原因,我认为有必要反转 Y 坐标。
推荐阅读
- reactjs - React Native Jest 单元测试:无法执行测试用例“无法读取未定义的属性参数”
- django - django 为对象创建随机 url 有效 id 序列
- sql - 得到不同列的总和
- integration - ADFS 与 Hybris 的集成
- python - Pivot - 通过重复的熊猫数据框转置列
- apache-flink - 如何通过IntelliJ的sbt添加Kafka连接器?我想添加通用连接器以支持 Kafka 2.3
- powershell - PowerShell 'q' 不会破坏 'more' 进程
- multithreading - 如何设计 Mutex 的可变集合?
- automation - cypress - 执行操作,直到元素显示在屏幕上
- dataframe - 如何获取几列的最大值并在数据框中创建一个新列