Cao*_*ang 7 video tracking ios arkit
我正在开发一个同时使用ARKit和硬件视频解码器的应用程序.一旦解码器开始解码,控制台中就会出现以下错误消息,并阻止跟踪正常工作.
有时,此错误不会显示,应用程序正常工作.经过一些调试后,我发现这个错误只发生在"开始"(启动应用程序后不久).一旦它通过该点,它在其余时间工作正常.
有谁知道问题是什么或如何绕过它?
2017-08-11 20:48:02.550228-0700 PortalMetal [4037:893878] [] <<<< AVCaptureSession >>>> - [AVCaptureSession _handleServerConnectionDiedNotification] :( 0x1c0007eb0)(pthread:0x170387000)ServerConnectionDied 2017-08-11 20 :48:02.564053-0700 PortalMetal [4037:893747] [会话]会话确实失败并显示错误:错误Domain = com.apple.arkit.error Code = 102"所需传感器失败." UserInfo = {NSLocalizedFailureReason =传感器未能提供所需的输入.,NSUnderlyingError = 0x1c4c51280 {错误域= AVFoundationErrorDomain代码= -11819"无法完成操作"UserInfo = {NSLocalizedDescription =无法完成操作,NSLocalizedRecoverySuggestion =稍后再试.}}, NSLocalizedRecoverySuggestion =确保应用程序具有所需的隐私设置.,NSLocalizedDescription =必需的传感器失败.}
解决方案是在手机设置中设置指南针校准。归功于这个答案。
进入设置 > 隐私 > 定位服务 > 系统服务,然后将指南针校准设置为开。
在类的顶部声明您的配置,例如:
var configuration = ARWorldTrackingConfiguration()并确保在viewWillAppear方法中设置并添加配置。
然后添加这个方法来处理错误。
func session(_ session: ARSession, didFailWithError error: Error) {
// Present an error message to the user
print("Session failed. Changing worldAlignment property.")
print(error.localizedDescription)
if let arError = error as? ARError {
switch arError.errorCode {
case 102:
configuration.worldAlignment = .gravity
restartSessionWithoutDelete()
default:
restartSessionWithoutDelete()
}
}
}
Run Code Online (Sandbox Code Playgroud)
它只是处理您注意到的错误。
接下来,添加此函数以使用新的配置 worldAlignment 重置会话:
func restartSessionWithoutDelete() {
// Restart session with a different worldAlignment - prevents bug from crashing app
self.sceneView.session.pause()
self.sceneView.session.run(configuration, options: [
.resetTracking,
.removeExistingAnchors])
}
Run Code Online (Sandbox Code Playgroud)
希望它有所帮助,我也希望找到对这个明显错误的实际修复。
设置worldAlignment为gravityAndHeading需要启用定位服务:
Privacy - Photo Library Additions Usage Description如果指南针方向对您的应用至关重要,您应该考虑引导用户打开位置服务并实施后备。
| 归档时间: |
|
| 查看次数: |
3186 次 |
| 最近记录: |