【问题标题】:Is it possible to hide Feature Points in ARKit?是否可以在 ARKit 中隐藏特征点?
【发布时间】:2017-09-02 15:05:09
【问题描述】:

我想在我的应用中引入一个开关,让用户可以启用或禁用功能点。

我说的功能是:

self.sceneView.debugOptions = [ARSCNDebugOptions.showFeaturePoints]

是否可以禁用它或仅以一种方式禁用它?

谢谢!

【问题讨论】:

    标签: ios swift augmented-reality arkit


    【解决方案1】:

    如果特征点是您打开的唯一调试选项,您可以通过将调试选项设置为空集轻松将其关闭(以及所有其他调试选项):

    self.sceneView.debugOptions = []
    

    如果您设置了其他调试选项并希望删除特征点之一,则需要采用当前的debugOptions 值并应用一些SetAlgebra 方法来删​​除你不想要的选项。 (然后将debugOptions 设置为您修改后的集合。)

    【讨论】:

    • 终于!非常感谢你!这非常容易,但在艰难的开发过程中需要考虑的东西太多......
    【解决方案2】:

    答案是肯定的

    您可以启用 / 禁用 Feature Points,即使其他debugOptionsON。您可以使用insert(_:)remove(_:) 实例方法来完成此操作。

    这是一个代码(Xcode 10.2.1、Swift 5.0.1、ARKit 2.0):

    let configuration = ARWorldTrackingConfiguration()
    @IBOutlet weak var `switch`: UISwitch!
    var debugOptions = SCNDebugOptions()
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        sceneView.delegate = self
        let scene = SCNScene(named: "art.scnassets/model.scn")!
        
        debugOptions = [.showWorldOrigin]
        sceneView.debugOptions = debugOptions
        sceneView.scene = scene
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        sceneView.session.run(configuration)
    }
    
    @IBAction func featurePointsOnOff(_ sender: Any) {
    
        if `switch`.isOn == true {
            debugOptions.insert(.showFeaturePoints)
            sceneView.debugOptions = debugOptions
            print("'showFeaturePoints' option is \(debugOptions.contains(.showFeaturePoints))")
    
        } else if `switch`.isOn == false {
            debugOptions.remove(.showFeaturePoints)
            sceneView.debugOptions = debugOptions
            print("'showFeaturePoints' option is \(debugOptions.contains(.showFeaturePoints))")
        }
    }
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2018-03-28
      • 1970-01-01
      • 2018-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-04
      • 2019-02-16
      相关资源
      最近更新 更多