【问题标题】:Augmented Reality - Distance between marker image and Camera in ArKit?增强现实 - ArKit 中标记图像和相机之间的距离?
【发布时间】:2018-04-06 06:25:18
【问题描述】:

我想计算保存在 iOS 项目中用于在增强现实中检测的任何标记图像与您当前位置(即使用 ARKIT 的相机位置)之间的距离?

【问题讨论】:

  • 请分享您的尝试。

标签: ios augmented-reality arkit


【解决方案1】:

作为 Apple 的 documentation and sample code 注意:

  • 检测到的图像会作为ARImageAnchor 对象报告给您的应用。
  • ARImageAnchorARAnchor 的子类。
  • ARAnchor 有一个 transform 属性,表示它在 3D 空间中的位置和方向。
  • ARKit 还在每一帧上为您提供ARCamera(或者您可以从会话的currentFrame 中获取它)。
  • ARCamera 还有一个 transform 属性,指示相机在 3D 空间中的位置和方向。
  • 您可以通过提取最后一个列向量得到translation vector (position) from a 4x4 transform matrix

这应该足以让您连接点......

【讨论】:

    【解决方案2】:

    如果您使用的是 SceneKit 并拥有 -(void) renderer:(id<SCNSceneRenderer>)renderer didAddNode:(SCNNode *)node forAnchor:(ARAnchor*)anchor 附带的 SCNNode*,那么 [node convertPosition:{0,0,0} toNode:self.sceneView.pointOfView].z 就是到相机的距离。

    【讨论】:

      猜你喜欢
      • 2018-05-08
      • 2018-12-06
      • 2019-02-27
      • 1970-01-01
      • 1970-01-01
      • 2023-01-18
      • 1970-01-01
      • 2019-11-26
      • 1970-01-01
      相关资源
      最近更新 更多