Augmented Reality – Moving cars with virtual buttons

Virtual buttons with ARToolKit5 and Android NDK

I recently came across a very cool Augmented Reality video that demonstrates the use of virtual buttons using ARToolKit5 with Unity3D. Following this idea, I created an example that does something similar but uses the C classes of ARToolKit5 with the Android NDK directly.

We are going to create an app that moves a Ferrari Modena Spider and a Porsche 911 GT3 left and right using virtual buttons.

Getting started

You need to have some basic things up and running before you can follow this tutorial:

Extending the sample

We use the ARSimpleNativeCarsProj example as a basis for your interactive Augmented Reality app.

The whole interaction idea is based on the absence of a marker in the camera stream. This means we implement an app that expects to find two specific markers in the camera stream. If one of these markers is missing we perform the interaction.

First, we add the new markers that we will use for the interactions. To do this we create an additional array that contains the new interaction markers.

Add the markers

Then we add our interaction markers to the ARToolKit framework at the end of the demoInitialize()  function.

 

Create the virtual button

Now inside the demoDrawFrame function, we check if these interactionModels are visible or not.
If they are not visible we perform the interaction.

 

Bring the virtual button to life

The interaction itself is fairly simple, we only modify the x-Coordinate of the model to move it to the left or to the right. We do this by saving the offset as an additional value on the model and add it to the transformation matrix prior to painting the model in the video stream.

Add up the offset:

Manipulate the transformation matrix:

 

Going forward

This is a simple example, how to get some interaction going using ARToolKit5 and the Android NDK. As this involves a basic understanding of programming and the C programming language a next step is to port this example to Unity3D to abstract it a bit from the programming part.

Additionally, it would be great if the markers used for the interaction would be smaller so they occupy less space.

Let me know your cool ideas and remarks about this example.

If you are interested in the whole functioning code you can get it from GitHub.

3 Comments

  1. small business help May 6, 2017
  2. Hing June 26, 2017
    • Thor_Bux June 29, 2017