Tracking Multiple Images - AR Foundation

Mapping different models to specific images

Posted by Yasthil Bhagwandeen on May 19, 2020 · 2 mins read

Background

Augmented Reality is a technology that has really taken the world by storm. I was fortunate enough to have worked on some AR apps early in my career and it has been amazing watching how Unity has evolved into one of the defacto engines for building MR content. Back in 2014, I used Unity and Vuforia to do basic image tracking and displaying a 3D model in AR. Nowadays, we are spoilt with a host of amazing free tools that’s built right into Unity!

AR Foundation

AR Foundation is Unity’s framework that provides the high-level AR functionalty. Instead of working directly with ARKit (Apple) and ARCore (Android) we can use a single framwork, whilst being able to deploy to both Android and Apple. More info here

Goal

I wanted to replicate what I did using Vuforia in the past, but using AR Foundation instead.

  • Have a bunch of QR codes as reference images (‘markers’)
  • Display a 3D model once the marker is scanned

Result

  • The scene is made up of:

    • Here, the ARTrackedImageManager does all the heavy lifting
    • You provide it with a ReferenceImageLibrary - which contains your images you want to use as markers (QR codes in my case)
    • Provide it with a Prefab that will be spawned once the marker is tracked
  • I wrote a script that maps the names of the reference images to the GameObject it’s mapped to. Thus allowing me to know which one to display.

Future

There are some improvements that I could make to this simple project:

  • Better handling of when the image looses tracking
  • Add some interaction perhaps

Resources