如何在会话 运行 期间修改 "AR Reference Image Set"?

How to modify "AR Reference Image Set" during session run?

在我的应用程序中,我拍摄了几张照片,我将这些照片作为 UIImages 添加到名为 imagesPicked 的数组中。我将该数组转换为一个集合,我通过按钮操作将其加载到配置中,然后我 运行 通过 resetTracking() 进行会话。所有这一切都通过以下代码。但我想修改该代码,以便能够将新图像添加到 AR 参考图像集(例如更改配置),同时仍然 运行ning,而无需重置会话。我怎样才能做到这一点?谢谢

var detectionImages = Set<ARReferenceImage>()
func resetTracking() {
        let configuration = ARWorldTrackingConfiguration()
        configuration.detectionImages = detectionImages
        session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
    } 


var index = 0
 func createARReferenceSet() -> Set<ARReferenceImage>?
{
        var customReferenceSet = Set<ARReferenceImage>()
        do{
            for i in 0...imagesPicked.count-1{
                let image = imagesPicked[i]
                let cgImage = image?.cgImage
                let imageWidth = CGFloat(0.1)
                let customARReferenceImage = ARReferenceImage(cgImage!, orientation: CGImagePropertyOrientation.up, physicalWidth: imageWidth)
                customARReferenceImage.name = "MyCustomARImage\(index)"
                customReferenceSet.insert(customARReferenceImage)
                index += 1
            }
            }
        return customReferenceSet
    }
}


@IBAction func detectChosenImage(_ sender: Any) {
        detectionImages = createARReferenceSet()!
        resetTracking()
    }

为了在不重置当前会话的情况下将图像添加到 AR 参考图像集中 运行 没有 [.resetTracking, .removeExistingAnchors] 选项的新配置,请尝试仅调用 session.run(configuration).