我指的是这个 Azure 文档来开发一个 ARKit iOS 应用程序来创建和定位 Azure 空间锚:https ://docs.microsoft.com/en-us/azure/spatial-anchors/how-tos/create-locate-anchors -迅速
但是,当我在项目设置中达到此步骤时:_cloudSession?.processFrame(self.sceneView.session.currentFrame)
我在 Xcode 中收到以下错误:
*** 由于未捕获的异常“SCCException”而终止应用程序,原因:“无效参数。(22)。提供的参数无效。请求相关向量:。ResponseCorrelationVector: ' *** First throw call stack: (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: terminating with NSException 类型的未捕获异常 *** 由于未捕获异常“SCCException”而终止应用程序,原因:“参数无效。(22)。提供的参数无效。请求相关向量:。响应相关向量:'
到目前为止,我的代码如下:
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 协议......”
任何帮助/见解将不胜感激!