Getting Started with ARToolKit+ Unity Plugin (Open Source AR) 15



DAQRI company announces a new milestone in the project augmented reality tools open source AR SDK, ARToolKit. The Americans started to open beta ARToolKit-5 on Linux, Android, iOS, macOS, and Unity. New updates abound functional part and distributed Apache v2.0 license so that developers can create their own applications with minimal licensing restrictions.

ARToolKit Demo

 

ARReverie added a new tracking method which will detect an ImageTarget without creating external Marker database by combining multiple tech together such as P3P and optical flow for a more reliable reading key.

The system recognizes and track supports multiple images based on detection initialization at speeds of tens of milliseconds. Calibration, identification, and tracking of fully autonomous kept up to hundreds of detected images; working dynamic loading and saving individual images or sets.

 


ARTOOlkit+ For Unity:

ARReverie provides ARToolKit+ plugin for Unity brings the full functionality of ARToolKit into the Unity3D visual development environment. It consists of a set of Unity script components which integrate seamlessly with your Unity project, native plugins which implement the underlying core functionality, and a set of examples and accompanying resources that act as starting points.

Note: Plugin cost 45$(One Time) only and this amount will help the ARReverie  Technology to explore the latest tech and transfer the knowledge.

 

System Requirements (Development & Deployment)

# Development Requirements:

  • Mac OS X min. Sierra (version 10.12.3)
  • X-Code min. Version 8.2.1 (Optional)
  • Android Studio v2.1 and later (Optional)
  • Unity3D  (min. 5.5 installed on a macOS X), the free, Personal Edition, is sufficient for a start
  • The Unity3D plugin of ARToolKit+: ARToolkit+ UnityPackage

# Development Requirements / Supported Target Platforms:

  • iOS v7.0 and later (armv7, armv7s, arm64)
  • Android v4.0.3 and later (armeabi-v7a, x86)
  • MacOS v10.7 and later (x86_64)

Let’s Start Developing an application using ARToolKit + Unity

As a quick start with Unity3D and ARToolKit+, we are using one of the default example scenes shipped with the ARToolKit+ Unity package. This Tutorial describes how to create and demonstrate augment reality application using the Unity3D IDE and the ARToolKit+ for Unity SDK.

For the first tutorial, we’re going start from scratch and create an application that recognizes an image exposed to the computer’s/Mobile’s camera, tracks the image and augments a 3D model in the video feed over the tracked image.

Prerequisite (Tools Needed):

As discussed earlier Support for ARToolKit+ for Unity and the Unity3D IDE on Windows 10 is under test and is forthcoming. “MacOS based Unity3D IDE” is recommended.

  • If you intend to build and deploy on Android, you’ll need to install Android SDK, which must include the NDK, Android Studio or Android command-line tools (for example, the Android ADB).
  • If you intend to build and deploy on iOS you’ll need to install XCode.

Here in this tutorial, we are targeting Android as a deployment Platform, We will be using ARToolkit+ AR SDK by ARReverie and Unity 3D engine and Android SDK for this tutorial. Make sure you have downloaded the following before proceeding further.

  1. Unity Engine (Version 2017.3 I’m using now)
  2. ARToolkit+ V2.0 SDK for Unity( ARToolkit-Unity 6.0.2-Development)
  3. ARToolkit Camera Calibration for macOS (Camera Calibration and ImageTarget Manager for OS-X)
  4. Android SDK & Android Studio (Optional)
  5.  Java Development Kit (JDK)

Step by Step Implementation

1. Setup a Simple Unity Project:

  • Unity is a powerful and widely used game engine. Let’s start by creating a new Unity3D project by the name of “ARToolKit_ImageTarget”. (Disable Unity Analytics for now)
  • Start Unity and enter a project name, browse to a location, enable the 3D radio button and click ‘Create Project’ button.

ARToolKit Unity Tutorial


2. Download & Install ARToolkit+ “Calibration Tool” for your Mac machine:

  • Download: “ARToolkit_Plus_macOS.dmg
  • Open download folder and run “ARToolKit_Plus_macOS.dmg” on your Mac Machine.
  • Once make sure that “ARToolKit for macOS “ properly get installed on your MacBook.
  • Now navigate to  “/Applications/artoolkit6/SDK/Applications/” through your Finder and open “ARToolKit6 Image Database Utility”
  • “ARToolKit+ Image Database Utility” is an offline utility provided by ARToolkit which help us to create/manage ImageTarget Database.

ARToolkit Installer For Mac OS


3. Import ARToolKit+ Unity packages inside Unity Asset Store:

  • Import the custom UnityPackage / ARToolKit+ Unity Extension/ARToolKit+ SDK (ARToolkit+ Unity Package)
  • To import a new custom package:
    1. Choose Assets > Import Package > Custom Package… to bring up File Explorer (Windows) or Finder (Mac).
    2. Select the package you want from Explorer or Finder, and the Import Unity Package dialog box displays, with all the items in the package pre-checked, ready to install. (See Fig 4: New install Import Unity Package dialog box.)
    3. Select Import and Unity puts the contents of the package into the Assets folder, which you can access from your Project View.

  • If any “API Update” related dialog box appears, just click on “I Made a Backup” and go ahead.

 


4. Open Unity-Scene “2DTrackerTest” from ARToolkit inside Unity Project:

  • Open Scene ‘2DTrackerTest’ inside Project window
  • Project >> Test Scene >>2DTrackerTest.unity
  • Then you are now able to see some game objects “ARToolkit“, “ISceneRoot“, “Marker scene 0” etc. inside Hierarchy window
  • Delete “Marker scene 0”, “Marker scene 2”, “Marker scene 3” from Hierarchy window as shown in fig. below.

IMP NOTE:  ARToolKit+ support Mac, Android, iOS or Linux as a deployment platform so we need to build the project for any of them inside Unity build settings. If there any error occurs like ‘ARToolKit+: Build target not supported’ just ignore it for now.

ARToolkit Scene import


5. Import 3D model (Spider) from Unity Assets Store:

Now the fun part begins!!! let’s download 3D model with some animations for our augmented reality. For this tutorial, we choose one Green Spider from Unity Asset Store (free).

  • You can open the Asset Store window by selecting ‘Window > Asset Store’ from the main menu. On your first visit, you will be prompted to create a free user account which you will use to access the Store subsequently.
  • Navigate to: ‘Window > Asse Store’ OR Select ‘Asset Store Tab’
  • In Asset Store window search for the keyword “Spider Green” and download the same, as shown in the screenshot below.

Import 3D Model


6. Add 3D model (Spider)  Inside ImageTarget in Unity Scene

Afterward, we introduce our 3D model (downloaded from Asset Store) into parent ImageTarget, to do this:

  • Expand Spider Green folder inside Unity Project window
  • For the 3D Spider to appear over ImageTarget/Marker, it needs to be made a child of “Marker scene1” (can be done by just dragging the SPIDER prefab in the Hierarchy panel).
  • Then, whenever the ImageTarget is detected by a mobile device’s camera, all the children of the target will also appear together.
  • Simply Drag & Drop SPIDER prefab inside ‘Marker scene 1’ in Hierarchy window.
  • Delete all ‘Cylinder’ and ‘Cone’ GameObjects from Hierarchy window as shown in fig. below.
  • Setup Spider Prefab: For ‘Spider’ 3d model maintain the Position, Rotation & Scale properties (mostly default)
    • Position:    X=0,           Y=0,       Z=0
    • Rotation:   X=-99.9,     Y=0,       Z=0
    • Scale:         X=0.03,      Y=0.03,  Z=0.03

Spider Scene Setup

NOTE: This AR app will work on ImageTarget/Marker_Image even with a black and white image of the stones because the feature points will still remain (they usually depend on other factors like gradient, etc. instead of color).

You can download Marker Image from here. The target image is required that your computer’s camera will recognize and track while demonstrating ARToolKit6 Augmented Realty example applications.


7. Android Deployment Setup to Run App on Device:

We are almost done. Let’s save the scene: File >> Save Scene and move towards deployment step. At this point, if we select “Run” and point a print out of the image towards our webcam, the Spider get augmented over printout.

The last step is to build the project for Android. We need to go to “File >> Build Settings”. We need to add the current scene by selecting “Add Open Scene”. Then, we need to select a platform (Android) and then select “Switch Platform“. Here, we will have multiple options:

  • Export Project: This will allow us to export the current Unity project to Android Studio so it can be edited and used to add more elements.
  • Development Build: Enabling this will enable Profiler functionality and also make the Autoconnect Profiler and Script Debugging options available.

Unity provides a number of settings when building for Android devices – select from the menu (File > Build Settings… > Player Settings…) to see/modify the current settings.

Unity to Android Deployment


 

Before pressing the Build And Run, we need to make some more changes in the “Player Settings” options in the Inspector panel:

  • The Company Name needs to be changed; e.g. to “ARReverie”.
  • Need to change the “Package Name” under “Identification” say, to “com.arreverie.artoolkitdemo”.

Now, we can proceed to “Build and Run”. Other changes like Minimum API Level etc. can be made as per additional requirements. We will need to connect an Android mobile device via USB and enable USB debugging.

NOTE: We will also need to have an Android developer environment set up before we can test our Unity games on the device. This involves downloading and installing the Android SDK with the different Android platforms and adding our physical device to our system (this is done a bit differently depending on whether we are developing on Windows or Mac).

If you get stuck at any point, feel free to post us in the comment section below.

‘If you stuck at any point’ OR ‘Do you have any questions about this tutorial?’ OR ‘Do you have any suggestions for a new AR tutorial?’ Let me know in the comments section below. 

Best of luck 🙂

 



Sanket Prabhu

About Sanket Prabhu

Sanket Prabhu is Technology Evangelist in XR (MR/AR/VR), Unity3D technology, a software engineer specializing in Unity 3D, Extended Reality (MR/AR/VR) application and game development. Currently working as a technology evangelist at Mobiliya, India. He runs a website (arreverie.com) which is the online blog and technical consultancy. The main goal of ARReverie is to develop complete open source AR SDK (ARToolKit+)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

15 thoughts on “Getting Started with ARToolKit+ Unity Plugin (Open Source AR)