【发布时间】:2017-11-09 08:46:50
【问题描述】:
如何实现垂直平面检测(即用于墙壁)?
let configuration = ARWorldTrackingSessionConfiguration()
configuration.planeDetection = .horizontal //TODO
【问题讨论】:
标签: swift augmented-reality arkit
如何实现垂直平面检测(即用于墙壁)?
let configuration = ARWorldTrackingSessionConfiguration()
configuration.planeDetection = .horizontal //TODO
【问题讨论】:
标签: swift augmented-reality arkit
编辑:现在从 ARKit 1.5 (iOS 11.3) 开始支持。只需使用.vertical。出于历史目的,我保留了之前的帖子。
垂直平面检测不是(还)存在于 ARKit 中的功能。 .horizontal 表明此功能可能正在开发中,将来可能会添加。如果它只是一个布尔值,这表明它是最终的。
我在 WWDC17 上与一位 Apple 工程师的谈话证实了这一怀疑。
您可能会争辩说,为此创建一个实现会很困难,因为垂直平面而不是水平平面有无限多的方向,但正如 rodamn 所说,情况可能并非如此.
来自 rodamn 的 评论:
在最简单的情况下,一个平面被定义为三个共面点。一旦沿表面(垂直、水平或任意角度)检测到足够多的共面特征,您就有了一个表面候选。只是水平线的法线将沿着上/下轴,而垂直线的法线将平行于地平面。挑战在于,朴素的干墙往往会产生很少的视觉特征,而普通的墙壁可能经常不会被发现。我强烈怀疑这就是.vertical 功能尚未发布的原因。
但是,对此有一个反驳。有关详细信息,请参阅 rickster 的 cmets。
【讨论】:
iOS 11.3 支持此功能:
static var vertical: ARWorldTrackingConfiguration.PlaneDetection会话检测与重力平行的表面(无论其他方向如何)。
https://developer.apple.com/documentation/arkit/arworldtrackingconfiguration.planedetection https://developer.apple.com/documentation/arkit/arworldtrackingconfiguration.planedetection/2867271-vertical
【讨论】:
Apple 发布的 iOS 11.3 将为 AR 提供各种更新,包括 ARKit 1.5。在本次更新中,ARKit 包括 ARKit 识别虚拟对象并将其放置在垂直表面(如墙壁和门)上的能力。
ARWorldTrackingConfiguration 现在支持垂直
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal, .vertical]
sceneView.session.run(configuration)
【讨论】:
由于 iPhone X 配备了前置深度摄像头,我怀疑下一个版本将采用后置摄像头,也许 .vertical 功能将在此之前被授权。
【讨论】:
我是用 Unity 做的,但我需要做数学。
我使用 Random Sample Consensus 从 ARkit 返回的点云中检测垂直平面。这就像有一个循环,随机选择 3 个点来创建一个平面并计算与之匹配的点,然后看看哪个尝试是最好的。
它正在工作。但是因为当墙壁是纯色时,ARkit 不能返回很多点。所以它在很多情况下都不起作用。
【讨论】:
在 ARKit 1.0 中,只有
.horizontalenum 用于检测水平表面,如桌子或地板。在 ARKit 1.5 及更高版本 中,PlaneDetectionstruct 的.horizontal和.vertical类型属性符合OptionSetprotocol .
要在 ARKit 2.0 中实现垂直平面检测,请使用以下代码:
configuration.planeDetection = ARWorldTrackingConfiguration.PlaneDetection.vertical
或者您可以对这两种类型的平面使用检测:
private func configureSceneView(_ sceneView: ARSCNView) {
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.horizontal, .vertical] //BOTH TYPES
configuration.isLightEstimationEnabled = true
sceneView.session.run(configuration)
}
您还可以向ARSceneManager 添加一个扩展来处理委托调用:
extension ARSceneManager: ARSCNViewDelegate {
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
guard let planeAnchor = anchor as? ARPlaneAnchor else {
return
}
print("Found plane: \(planeAnchor)")
}
}
【讨论】:
据说苹果正在为新 iPhone 开发额外的 AR 功能,即为相机增加额外的传感器。当这些设备功能已知时,也许这将成为一项功能。这里有些猜测。 http://uk.businessinsider.com/apple-iphone-8-rumors-3d-laser-camera-augmented-reality-2017-7 和另一个来源 https://www.fastcompany.com/40440342/apple-is-working-hard-on-an-iphone-8-rear-facing-3d-laser-for-ar-and-autofocus-source
【讨论】: