gpt4 book ai didi

swift - ARKit 的图像识别是否可以对同一张图像进行两次或更多次检测?

转载 作者:行者123 更新时间:2023-11-28 13:58:34 24 4
gpt4 key购买 nike

我正在尝试构建一个应用程序来检测同一张图像两次或更多次,并将这些检测到的图像添加到一个数组中,以便稍后对其进行处理。

我将图像和尺寸添加到 Assets.xassets 中的 AR Resources 文件夹中。图像被识别并且工作正常。但是当我想扫描同一张图片两次时,它只能识别一张图片。

我没有在 Internet 上找到有关此问题的任何特定文档。我还怀疑 ARKit 是不可能的,我可能需要使用机器学习模型。

如果有人遇到这个问题并且有没有 CoreML 和 Vision 的解决方案,我们将不胜感激。否则我会尝试让它与视觉和 CoreML 一起工作。

下面是识别图像并在其上方广告透明平面的代码。

func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
guard let imageAnchor = anchor as? ARImageAnchor else { return }
let referenceImage = imageAnchor.referenceImage
let imageName = referenceImage.name ?? "no name"

print("Image Anchor: ", imageAnchor)

let plane = SCNPlane(width: referenceImage.physicalSize.width, height: referenceImage.physicalSize.height)
let planeNode = SCNNode(geometry: plane)
planeNode.opacity = 0.20
planeNode.eulerAngles.x = -.pi / 2
node.addChildNode(planeNode)

detectedImages.append(imageAnchor)

DispatchQueue.main.async {
self.label.text = "Image detected: \"\(imageName)\""
}
}

最佳答案

您发布的代码无法识别任何内容,当 ARKit 已经为已识别图像添加的 anchor 添加默认节点时调用它,这确实只发生一次。如果要规避此限制,请遵循手册 -

Consider when to allow detection of each image to trigger (or repeat) AR interactions. ARKit adds an image anchor to a session exactly once for each reference image in the session configuration’s detectionImages array. If your AR experience adds virtual content to the scene when an image is detected, that action will by default happen only once. To allow the user to experience that content again without restarting your app, call the session’s remove(anchor:) method to remove the corresponding ARImageAnchor. After the anchor is removed, ARKit will add a new anchor the next time it detects the image.

https://developer.apple.com/documentation/arkit/recognizing_images_in_an_ar_experience

关于swift - ARKit 的图像识别是否可以对同一张图像进行两次或更多次检测?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53722871/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com