Home

Awesome

CoreML-in-ARKit

This simple project detects objects in Augmented Reality and displays 3D labels on top of them. This serves as a basic template for an ARKit project to use CoreML.

image of scene with 3d labels on objects

Demo Video - on Youtube

Model: Inception V3

Language: Swift 4.0

Written in: Xcode 9.0 GM (9A235) (Updated) XCode 9 beta 3 (9M174d)

Content Technology: SceneKit

Tested on iPhone 7 plus running iOS 11 beta 3 (15A5318g)

Note: SceneKit can achieve a 60 FPS on iPhone7+ - though when it gets hot, it'll drop to 30 FPS.

Instructions

You'll have to download "Inceptionv3.mlmodel" from Apple's Machine Learning page, and copy it into your XCode project. (As depicted in the following gif)

Gif to show dragging and dropping of model into XCode

(Gif via Atomic14)

If you're having issues, double check that the model is part of a target (source: stackoverflow).

Footnotes

Building Blocks (Overview)

Get CoreML running in real time in ARKit

let pixbuff : CVPixelBuffer? = (sceneView.session.currentFrame?.capturedImage)
let dispatchQueueML = DispatchQueue(label: "com.hw.dispatchqueueml")
...
loopCoreMLUpdate() // on viewLoad
...
func loopCoreMLUpdate() {
    dispatchQueueML.async {
        // 1. Run Update.
        self.updateCoreML()
        // 2. Loop this function.
        self.loopCoreMLUpdate()
    }
}

Add 3D Text