在一个新项目中,我们计划创建以下 AR 展示:
我们想要一堵墙,上面有一些管道和电缆。这些将安装传感器以控制和监控管道/电缆系统。由于每个传感器都具有相同的尺寸和外观,我们计划为每个传感器添加单独的二维码。阅读 ARWorldTrackingConfiguration 的文档和 ARImageTrackingConfiguration显示 ARKit 能够识别已知图像。但是对图像的要求让我想知道当使用多个 QR 码时应用程序是否会按照我们想要的方式工作:
来自 detectionImages :
[...], identifying art in a museum or adding animated elements to a movie poster.
来自 Apples 主题演讲:
Good Images to Track: High Texture, High local Contrast, well distributed histogram, no repetitive structures
由于 QR 码不完全符合要求,我想知道是否可以使用大约 10 个 QR 码并让 ARKit 单独且可靠地识别它们中的每一个。特别是当例如3 代码在 View 中。有没有人有跟踪多个 QR 码或类似陈列柜的经验?
最佳答案
识别(多个)QR 码与 ARKit 无关,可以通过 3 种不同的方式(AVFramework、CIDetector
、Vision)完成,我认为后者更可取,因为你可能还想使用它的对象跟踪功能 (VNTrackObjectRequest)。根据我的经验,它也更强大。
如果您需要使用 QR 码的位置将对象放置在 ARKit 场景中,您将需要在 ARFrame 上执行 hitTest
以找到代码在世界中的 3D 位置(变换)。在该位置,您需要放置一个自定义 ARAnchor。使用 anchor ,您可以将自定义 SceneKit 节点添加到场景中。
更新:因此建议的策略是:1. 使用 Vision 查找 QR 码及其 2D 位置,2. 使用 查找其 3D 位置 (
, 3. 创建自定义(子类)worldTransform
) >ARFrame.hitTest()ARAnchor
并将其添加到 session 中, 4. 在 renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor )
为您的自定义 ARAnchor
添加自定义节点(例如 SCNText
with billboard constraint)。
如果你有机会使用 RxSwift,它可以使用 RxVision 框架完成最简单的工作,因为它允许轻松地将相关的 ARFrame 传递到处理程序中 -
var requests = [RxVNRequest<ARFrame>]()
let barcodesRequest: RxVNDetectBarcodesRequest<ARFrame> = VNDetectBarcodesRequest.rx.request(symbologies: [.QR])
self
.barcodesRequest
.observable
.observeOn(Scheduler.main)
.subscribe { [unowned self] (event) in
switch event {
case .next(let completion):
self.detectCodeHandler(value: completion.value, request: completion.request, error: completion.error) // define the method first
default:
break
}
}
.disposed(by: disposeBag)
关于ios - 几个带有 ARKit 的二维码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53003940/