我在初始化ARBodyTrackingConfiguration的ARView上使用ARSessionDelegate。
使用didAdd: [ARAnchor]和didUpdate: [ARAnchor]的session方法被正确调用。但是didRemove: [ARAnchor]从未被调用过。
根据official documentation的说法,锚点“可以”自动从会话中删除,这取决于会话配置。不过,我没有找到这样的设置。
有人知道为什么不调用带有didRemove [ARAnchor]的session方法吗?我需要更改哪个设置才能使它工作?
import ARKit
import RealityKit
import UIKit
class AugmentedVideoView: ARView, ARSessionDelegate {
func session(_ session: ARSession, didAdd anchors: [ARAnchor]) {
print("didAdd") // called correctly
}
func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
print("didUpdate") // called correctly
}
func session(_ session: ARSession, didRemove anchors: [ARAnchor]) {
print("didRemove") // is never called :-(
}
required init(frame: CGRect) {
#if targetEnvironment(simulator)
super.init(frame: frame)
handleError("Camera not available in simulator.")
return
#else
super.init(frame: frame,
cameraMode: ARView.CameraMode.ar,
automaticallyConfigureSession: false)
self.session.delegate = self
guard ARBodyTrackingConfiguration.isSupported else {
handleError("Your device does not support body tracking.")
return
}
let configuration = ARBodyTrackingConfiguration()
configuration.automaticSkeletonScaleEstimationEnabled = false
self.session.run(configuration)
#endif
}
@available(*, unavailable)
dynamic required init?(coder decoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}发布于 2019-12-04 18:37:34
好的,我想我现在已经明白了。即使这个人不再被检测到,ARKit也只是假设它仍然是最后一次被检测到的地方。这适用于例如在看不见人的情况下。如果该人不在视线范围内,并且检测到另一个人,则ARKit不够聪明,无法将其检测为另一个人。它只是更新旧的锚点,假设它是同一个锚点。
https://stackoverflow.com/questions/58910811
复制相似问题