首页 > 解决方案 > ARKit 人物遮挡 (.personSegmentationWithDepth) 冻结相机 (ARSceneView)

问题描述

当我在 ARKit 中切换到人物遮挡 (.personSegmentationWithDepth) 时,ARSCNView 有时会冻结。在 iOS 14.1 之前,下面的这段代码对我来说效果很好。或者。现在,切换到 .personSegmentationWithDepth 时相机不会冻结只是运气

func setupScene() {
    sceneView.delegate = self
    sceneView.session.delegate = self
    sceneView.autoenablesDefaultLighting = true
    sceneView.scene = scene
  }

  func initSceneSession() {
    let configuration = ARWorldTrackingConfiguration()
    configuration.planeDetection = .horizontal
    sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
  }

 func switchPeopleOcc(on: Bool){
    guard let config = sceneView.session.configuration as? ARWorldTrackingConfiguration,
      ARWorldTrackingConfiguration.supportsFrameSemantics(.personSegmentationWithDepth) else {            return
    }
    
    switch on {
    case true:
      config.frameSemantics.insert(.personSegmentationWithDepth)
    case false:
      config.frameSemantics.remove(.personSegmentationWithDepth)
    }
    
    sceneView.session.run(config)
  }

标签: swiftarkit

解决方案


推荐阅读