首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LiDAR深度+视觉手跟踪用于三维手跟踪

LiDAR深度+视觉手跟踪用于三维手跟踪
EN

Stack Overflow用户
提问于 2021-04-24 11:15:13
回答 1查看 623关注 0票数 2

我想使用视觉2D手跟踪输入与ARKit >人员遮挡>身体分割与深度,利用LiDAR,得到三维世界坐标的顶端的索引。

我正在做的步骤:

1-视觉提供的指尖的2D屏幕位置

来自CVPixelBuffer的深度数据似乎也是正确的。

3-从二维屏幕坐标+深度数据到三维世界坐标的未投影是错误的

理想情况下,我可以得到一个类似于乔希卡巴茨的LiDAR实验室应用程序的结果:

下面是我的代码,它将2D点坐标+深度处理为三维世界坐标:

代码语言:javascript
复制
// 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

你知道我的计算有什么问题吗?

EN

回答 1

Stack Overflow用户

发布于 2022-05-13 12:16:35

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67242166

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档