Developer Guide

Tutorial: Using on-device Augmented Reality on Android with CraftAR

icon Date Developer Guide

icon Date Dec 17, 2020

icon author Catchoom Team

icon folder

This section applies only to the Augmented Reality SDK v4 +.

The CraftAR Android Augmented Reality SDK allows you to create AR apps that render the experiences created with the CraftAR service. If you’re not yet familiar with the general steps, read How to add augmented reality into your app.

If you want to see an example that combines on-device collections with Tracking, take a look at the open-source samples available in our Github repository (on-device AR example).

In this article we explain how to create Augmented Reality apps using on-device collections. This allows to embed the AR items and their contents into the app and start Tracking without the need to load the items and the contents from the network.

An on-device Augmented Reality app using the iOS native SDK can be implemented following three steps.

  1. Add the on-device collection to the device;
  2. set up the SDK in your UIVIewController;
  3. trigger Augmented Reality experience.

This tutorial covers the second and third steps. For the first step, have a look at the tutorial on Managing on-device collections for the Android SDKs

Set up the SDK in your CraftARActivity

Once you have set up the CraftARSDK into your Android project, and added the collection bundle to your app , it’s time to implement the CraftARActivity that will show the experience.

1. Create a CraftARCameraView in your layout. This is the view that will show the AR experience.

2. Make your Activity extend from CraftARActivity, start the camera capture, and obtain the CraftARTracking instance

You will have to implement the methods onPostCreate(), onPreviewStarted(), and onCameraOpenFailed(). Obtain the CraftARSDK instance and start the camera capture:

Triggering Augmented Reality experience

Once your ViewController has the necessary protocols and instance of Tracking, it’s time to add code to start using the iOS Augmented Reality SDK for a mobile app.

In this case, we will load the items from an on-device collection we have previously added to the device. The following snippet shows how to traverse a collection’s items and add them for Tracking.

When the ARItems are loaded and startTracking() has been invoked, you can point to the object and the Augmented Reality experience will be shown.

Related Posts in Developer Guide