Code Monkey home page Code Monkey logo

mlkit-arkit's Introduction

MLKit-ARKit

This simple project detects objects using Firebase ML Kit and tags them in with 3D labels in Augmented Reality.

Based on: CoreML-in-ARKit

Demo gif

Demo Video

Language: Swift 4.0

Content Technology: SceneKit, Firebase ML Kit

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

Footnotes

  • SceneKit Text Labels are expensive to render. Too many polygons (too much text, smoothness, characters) - can cause crashes. In future, SpriteKit would be more efficient for text-labels.

  • Whilst ARKit's FPS , is displayed - ML Kit's speed is not. However, it does appear sufficiently fast for real-time ARKit applications.

  • Placement of the label is simply determined by the raycast screen centre-point to a ARKit feature-point. This could be altered for more stable placement.

Building Blocks (Overview)

Get ML Kit running in real time in ARKit

  • What we do differently here is we're using ARKit's ARFrame as the image to be fed into ML Kit.
let pixbuff : CVPixelBuffer? = (sceneView.session.currentFrame?.capturedImage)
  • We also use Threading to continuously run requests to ML Kit in realtime, and without disturbing ARKit / SceneView
let dispatchQueueML = DispatchQueue(label: "dispatchqueueml")
...
loopMLKitUpdate() // on viewLoad
...
func loopMLKitUpdate() {
    dispatchQueueML.async {
        // 1. Run Update.
        self.updateMLKit()
        // 2. Loop this function.
        self.loopMLKitUpdate()
    }
}

Add 3D Text

  • Add a Tap Gesture.
  • On Tap. Get the raycast centre point, translating it to appropriate coordinates.
  • Render 3D text at that location. Use the most likely object.

mlkit-arkit's People

Contributors

ulukaya avatar

Stargazers

PHM Bergonia avatar

Watchers

James Cloos avatar

Forkers

arkraybergonia

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.