我使用 ARKit 1.5 和这个函数来突出显示垂直表面,但效果不是很好。
func createPlaneNode(planeAnchor: ARPlaneAnchor) -> SCNNode {
let scenePlaneGeometry = ARSCNPlaneGeometry(device: metalDevice!)
scenePlaneGeometry?.update(from: planeAnchor.geometry)
let planeNode = SCNNode(geometry: scenePlaneGeometry)
planeNode.name = "\(currPlaneId)"
planeNode.opacity = 0.25
if planeAnchor.alignment == .vertical {
planeNode.geometry?.firstMaterial?.diffuse.contents = UIColor.red
}
currPlaneId += 1
return planeNode
}
它总是在垂直对象上找到一些特征点,但很少见它实际上使用我创建的 planeNode 突出显示了表面。
我希望能够检测并突出显示柱子甚至人之类的东西。你会如何处理这个问题? Image of object with featurePoints Image with the result in best case scenario
最佳答案
在 ARKit 1.5 和 ARKit 2.0 中有 .planeDetection
实例属性允许你启用 .horizontal
, .vertical
,或同时进行 .horizontal 和 .vertical
检测。
var planeDetection: ARWorldTrackingConfiguration.PlaneDetection { get set }
ViewController 的代码:
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = .vertical
//configuration.planeDetection = [.vertical, .horizontal]
sceneView.session.run(configuration)
如果您想成功检测和跟踪环境中的垂直物体,您需要良好的照明条件和丰富的非重复纹理。看下图:
关于swift - ARKit 1.5 – 垂直物体检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49671310/