【问题标题】:Azure Spatial Anchors: Setting up project in iOSAzure 空间锚点:在 iOS 中设置项目
【发布时间】:2021-11-29 07:29:52
【问题描述】:

我指的是这个 Azure 文档来开发一个 ARKit iOS 应用程序来创建和定位 Azure 空间锚:https://docs.microsoft.com/en-us/azure/spatial-anchors/how-tos/create-locate-anchors-swift

但是,当我在项目设置中达到这一步时:_cloudSession?.processFrame(self.sceneView.session.currentFrame)

我在 Xcode 中收到以下错误:

*** 由于未捕获的异常“SCCException”而终止应用程序,原因:“参数无效。 (22)。提供的参数无效。请求相关向量:。响应相关向量:' *** 首先抛出调用堆栈: (0x18469986c 0x1996b4c50 0x1845924a4 0x106c00bac 0x104ab9ef8 0x104ab9f8c 0x1b8a3aec8 0x1b8a3d830 0x1b8a3de20 0x1b8a3e204 0x1b8ae09a0 0x1b8995958 0x1b8aa9be0 0x10c8896c0 0x10c899f14 0x1b8aa9b64 0x18796b6fc 0x187a44a80 0x1845f0dd0 0x184615fe8 0x184615378 0x18460f08c 0x18460e21c 0x1858bddf0 0x1b8995ea4 0x1b89961bc 0x1d0147cb0 0x1d0150778) libc++abi.dylib:以 NSException 类型的未捕获异常终止 *** 由于未捕获的异常“SCCException”而终止应用程序,原因:“无效参数。 (22)。提供的参数无效。请求相关向量:。响应相关向量:' 以 NSException 类型的未捕获异常终止

到目前为止我的代码如下:

class ViewController: UIViewController, ARSCNViewDelegate, ASACloudSpatialAnchorSessionDelegate {

@IBOutlet var sceneView: ARSCNView!

var _cloudSession : ASACloudSpatialAnchorSession? = nil

// Set this string to the account ID provided for the Azure Spatial Anchors account resource.
let spatialAnchorsAccountId = "****************************************"

// Set this string to the account key provided for the Azure Spatial Anchors account resource.
let spatialAnchorsAccountKey = "****************************************"

// Set this string to the account domain provided for the Azure Spatial Anchors account resource.
let spatialAnchorsAccountDomain = "eastus.mixedreality.azure.com"

override func viewDidLoad() {
    super.viewDidLoad()
    
    sceneView.delegate = self              // set the view's delegate
    sceneView.showsStatistics = false      // show statistics
    sceneView.scene = SCNScene()
    
    // initializing the session
    _cloudSession = ASACloudSpatialAnchorSession()
    
    // start session
    _cloudSession!.session = self.sceneView.session;
    _cloudSession!.logLevel = .information
    _cloudSession!.delegate = self;
    
    // set auth
    _cloudSession!.configuration.accountId = spatialAnchorsAccountId
    _cloudSession!.configuration.accountKey = spatialAnchorsAccountKey
    _cloudSession!.configuration.accountDomain = spatialAnchorsAccountDomain
    
 
    _cloudSession!.start()
    
}

func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
    if let cloudSession = _cloudSession {
        cloudSession.processFrame(sceneView.session.currentFrame)
    }
} 

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    
    // Create a session configuration
    let configuration = ARBodyTrackingConfiguration()
    
    // Run the view's session
    sceneView.session.run(configuration)
}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    
    // Pause the view's session
    sceneView.session.pause()
}

示例 iOS 应用程序对我有用,但是按照从头开始构建项目的设置过程步骤让我感到困惑。

我也不清楚文档中的这句话:“...这个对象必须实现 SSCCloudSpatialAnchorSessionDelegate 协议...”

任何帮助/见解将不胜感激!

【问题讨论】:

    标签: ios swift azure arkit azure-spatial-anchors


    【解决方案1】:

    您可能需要查看documentation on protocol ASACloudSpatialAnchorSessionDelegate (Objective-C) 了解更多详情。

    代码行_cloudSession!.delegate = self; 指定ViewController 类应该遵循ASACloudSpatialAnchorSessionDelegate 协议,它确实这么说:

    class ViewController: ... ASACloudSpatialAnchorSessionDelegate ,这已经是一个好的开始了。

    文件中缺少的可能是ASACloudSpatialAnchorSessionDelegate 方法的实现,例如anchorLocatedsessionUpdatederror 等。这些方法通常由ASACloudSpatialAnchorSession 在其操作期间调用。您可以参考 Swift 示例了解这些方法的实现方式。

    而且,看来你可能想改变

    let configuration = ARBodyTrackingConfiguration()let configuration = ARWorldTrackingConfiguration()

    因为它与世界追踪有关。

    【讨论】:

      猜你喜欢
      • 2021-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多