如何解决用于 3D 手部跟踪的 LiDAR 深度 + 视觉手部跟踪
我想使用 Vision 2D Hand Tracking input 和 ARKit > People Occlusion > Body Segmentation With Depth,利用 LiDAR 来获得索引尖端的 3D 世界坐标。
我正在做的步骤:
1 - Visionworks 提供的指尖的 2D 屏幕位置
2 - 来自 CVPixelBuffer 的深度数据似乎也正确
3 - 从 2D 屏幕坐标 + 深度数据到 3D 世界坐标的反投影是错误的
理想情况下,我可以得到类似于 Josh Caspersz 的 LiDAR Lab 应用程序的结果:
这是我将 2D 点坐标 + 深度处理为 3D 世界坐标的代码:
// 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)
}
}
}
这是一个运行时的视频,它似乎总是位于空间中的特定区域: Video
计算基本上是来自示例代码Displaying a Point Cloud Using Scene Depth
如果您想自己尝试,最后这里是完整的 zip 文件:ZIP。
知道我的计算有什么问题吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。