Developer Guide

Tutorial: Use Tracking on Android with CraftAR Augmented Reality SDK

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 +. Are you still using an older version? Previous versions of the SDKs will not receive updates anymore. If you need help transitioning to the newer version, you can get support through our support channel.

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.

An Augmented Reality app using the Android native SDK can be implemented following two steps. First, you need to set up the CraftARActivity and then you can trigger Augmented Reality experiences.

If you want to see an example that combines Cloud Image Recognition (see Tutorial: Use Cloud Image Recognition on Android ) with Tracking, take a look at the open source samples available in our Github repository: https://github.com/Catchoom/craftar-example-android.

Set up the SDK in your CraftARActivity

Once you have set up the CraftARSDK into your Android project, 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:

Rendering Augmented Reality

To perform tracking, you have to load objects of the class CraftARItemAR to the tracking instance. A CraftARItemAR is a special type of CraftARItem that describes an AR experience. To obtain a CraftARItem:

  • If you’re using Cloud Image Recognition, you can obtain the CraftARItems in the searchResults() callback after a succesful image recognition request.
  • If you’re using On-Device Augmented Reality, you can list the available items in the collection using CraftAROnDeviceCollection.listItems(), and obtain an item using CraftAROnDeviceCollection.getItem(itemUUID)

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