我想使用视觉2D手跟踪输入与ARKit >人员遮挡>身体分割与深度,利用LiDAR,得到三维世界坐标的顶端的索引。
我正在做的步骤:
1-视觉提供的指尖的2D屏幕位置
来自CVPixelBuffer的深度数据似乎也是正确的。
3-从二维屏幕坐标+深度数据到三维世界坐标的未投影是错误的
理想情况下,我可以得到一个类似于乔希卡巴茨的LiDAR实验室应用程序的结果:

下面是我的代码,它将2D点坐标+深度处理为三维世界坐标:
// Result from Vision framework
// Coordinates top right of the screen with Y to the left, X down
indexTip = CGPoint(x:(indexTipPoint.location.x) * CGFloat(arView.bounds.width),
y:(1 - indexTipPoint.location.y) * CGFloat(arView.bounds.height))
if let segmentationBuffer:CVPixelBuffer = frame.estimatedDepthData {
let segmentationWidth = CVPixelBufferGetWidth(segmentationBuffer)
let segmentationHeight = CVPixelBufferGetHeight(segmentationBuffer)
let xConverted:CGFloat = indexTip.x * CGFloat(segmentationWidth) / CGFloat(arView.bounds.width)
let yConverted:CGFloat = indexTip.y * CGFloat(segmentationHeight) / CGFloat(arView.bounds.height)
if let indexDepth:Float = segmentationBuffer.value(column: Int(xConverted), row: Int(yConverted)) {
if indexDepth != 0 {
let cameraIntrinsics = frame.camera.intrinsics
var xrw: Float = (Float(indexTip.x) - cameraIntrinsics[2][0]) * indexDepth
xrw = xrw / cameraIntrinsics[0][0]
var yrw: Float = (Float(indexTip.y) - cameraIntrinsics[2][1]) * indexDepth
yrw = yrw / cameraIntrinsics[1][1]
let xyzw: SIMD4<Float> = SIMD4<Float>(xrw, yrw, indexDepth, 1.0)
let vecResult = frame.camera.viewMatrix(for: .portrait) * xyzw
resultAnchor.setPosition(SIMD3<Float>(vecResult.x, vecResult.y, vecResult.z), relativeTo: nil)
}
}
}以下是运行时的视频,似乎总是位于太空中的一个特定区域:视频
这些计算基本上是来自示例代码用场景深度显示点云的计算。

最后,这里是完整的zip文件,如果您想自己尝试的话:ZIP。
你知道我的计算有什么问题吗?
发布于 2022-05-13 12:16:35
https://stackoverflow.com/questions/67242166
复制相似问题