swift - ARKit 1.5 – 垂直物体检测

标签 swift augmented-reality arkit

我使用 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 实例属性允许你启用 .horizo​​ntal, .vertical,或同时进行 .horizo​​ntal 和 .vertical 检测。

var planeDetection: ARWorldTrackingConfiguration.PlaneDetection { get set }

ViewController 的代码:

let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = .vertical
//configuration.planeDetection = [.vertical, .horizontal]
sceneView.session.run(configuration)

如果您想成功检测和跟踪环境中的垂直物体,您需要良好的照明条件和丰富的非重复纹理。看下图:

enter image description here

关于swift - ARKit 1.5 – 垂直物体检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49671310/

相关文章:

ios - 在 Swift 中使用 xib 创建 UIView

swift - 将阴影转换到 ARKit 中的 SCNNode

swift - 解析保存后云函数返回成功结果但不执行成功函数

ios - Xcode 8 Frame for "Navigation Bar"will be different at run time error

ios - UICollectionView 没有出现在模拟器中

ios - 在 ARSCNView Aspect Fit 中加载大型 3d Object .scn 文件以适应屏幕 ARKIT Swift iOS

swift - 当对象不再在相机框架中时,如何删除 ARReferenceObject Anchor?

web - Web 浏览器的无标记 AR?

android - 为什么 ARCore 不支持 Nexus 9?

swift - ARKit 和 SceneKit 中的遮挡 Material 或保持着色器