Apple Vision图像识别

Apple Vision image recognition

与许多其他开发人员一样,我已经投入到 Apple 的新 ARKit 技术中。这很棒。 然而,对于一个特定的项目,我希望能够识别场景中的(真实生活中的)图像,或者在其上投影一些东西(就像 Vuforia 对其目标图像所做的那样),或者使用它来触发事件我的申请。

在研究如何实现这一点时,我偶然发现了 Apple 的 Vision 和 CoreML 框架。这看起来很有希望,尽管我还没有完全理解它。

据我了解,我应该能够通过使用 Vision 框架查找矩形并将其输入到 CoreML 模型中来做我想做的事情,该模型只需将其与我在模型中预定义的目标图像进行比较。然后它应该能够吐出它找到的目标图像。

虽然我觉得这听起来不错,但我还没有找到实现它的方法。我将如何着手创建这样的模型,甚至有可能吗?

几周前我在 Github 上发现了这个项目: AR Kit Rectangle Detection

我认为这正是您要找的...

从 ARKit 1.5(2018 年 spring 中的 IOS 11.3 开始),一项功能似乎直接在 ARKit 之上实现,解决了这个问题。

ARKit将全面支持图像识别。 识别图像后,可以检索 3d 坐标作为锚点,因此可以将内容放在上面。

Vision 检测图像的能力是从 iOS 11.3+ 开始在 ARKit 中实现的,所以从那时起 ARKit 有 ARImageAnchor subclass 扩展 ARAnchor parent class 并符合 ARTrackable 协议。

// Classes hierarchy and Protocol conformance...

ObjectiveC.NSObject: NSObjectProtocol
        ↳ ARKit.ARAnchor: ARAnchorCopying
                ↳ ARKit.ARImageAnchor: ARTrackable

ARWorldTrackingConfiguration class has a detectionImages instance property that is actually a set of images that ARKit attempts to detect in the user's environment.

open var detectionImages: Set<ARReferenceImage>!

And ARImageTrackingConfiguration class has a trackingImages instance property that is a set as well, it serves the same purpose – ARKit attempts to detect and track it in the user's environment.

open var trackingImages: Set<ARReferenceImage>

因此,通过正确的配置和在 ARSession 中自动获取 ARImageAnchor 的能力,您可以将任何几何图形绑定到该锚点。

P.S. 如果您想知道如何在您的 ARKit 应用程序中实现图像检测功能,请查看 .