我希望使用 ARKit 和 RealityKit 来检测 2D 图像。因为很多基于 RealityKit 的实现,所以不想使用 SceneKit。我找不到任何在 RealityKit 上检测图像的示例。我参考了苹果的示例代码。它使用 Scenekit 和
ARSCNViewDelegate
。let arConfiguration = ARWorldTrackingConfiguration()
arConfiguration.planeDetection = [.vertical, .horizontal]
arConfiguration.isLightEstimationEnabled = true
arConfiguration.environmentTexturing = .automatic
if let referenceImages = ARReferenceImage.referenceImages(inGroupNamed: "sanitzer", bundle: nil) {
arConfiguration.maximumNumberOfTrackedImages = 1
arConfiguration.detectionImages = referenceImages
}
self.session.run(arConfiguration, options: [.resetTracking, .removeExistingAnchors])
我已经实现了ARSessionDelegate
,但是无法检测到图像?
func session(_ session: ARSession, didAdd anchors: [ARAnchor]) {
//how to capture image anchor?
}
func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) {
//how to capture image anchor?
}
苹果已经实现了ARSCNViewDelegate
来捕获检测到的图像。在RealityKit中,相当于ARSCNViewDelegate的委托是什么?如何检测ARImageAnchor?