Simple Augmented Reality Android Application Tutorial using Unity and Vuforia SDK


Unity Integration

Unity is said to be one of the powerful tool used widely in game engine. In recent time, it has been emerged as one of the game engine for HMDs. Let us discuss Unity3D project with the name of “AR Demo”.

For this project we have to use Vuforia option that is found in Unity tool. Vuforia is a software used for creating Augmented Reality apps. Any Developers can easily add this to the advanced computer vision option to any application that allows it to recognize images, objects and to interacts with objects in real world.

To set Image for augmented reality application in Vuforia

Vuforia is said to be one of the best SDK used for image tracking in AR application. There are so many SDK available like Entity AR, Layar, Wikitude etc. In these SDK some are free to use and some are paid. But mostly, Vuforia is used for image tracking. It is free to use and has better image tracking system. We can use Vuforia for image tracking, target etc. To download Vuforia we have to go to website link . When you have it downloaded, open the Vuforia developer portal. If you have not used Vuforia before, then you will haveto register on its developer site. When you have done that, go to its "Develop" segment.

Now, add license key to the new project or we can take use of existing one also. We have to fill all the details along with its name.

Now, we have to confirm the license key in the next step. The encrypted text format is the license key. Now, we can use it in our Unity project.

Next step is to create target for image targets. And browse for “Target Manager”, that is next to “License Key” option. Now, add a new database for image targets.

Now, select the database that we have created and choose “Add Target” option to upload the images we want to track. The image should not be greater than 2MB. Otherwise, it gives an error message.

We can also modify and resize the shape of image with the help of tool. Once it has been uploaded we can the see the stars that is number of grades. The more the stars, obviously the easier and better the tracking will be. So, we have to try to have an image with stars of 5.

Here we can also see the tracking sites on the image too. Here, we are discussing, laptop keypad as tracking image. Just click on the image on the new window then it will show the image and also the tracking points for the image also.

Now, finally we can easily download the database via Vuforia SDK tutorial.

Now, importing Vuforia Unity packages. It can be done by option “Assets>>Import Package>>Custom Package”. For this it has two packages. One belongs to dataset (Image_Target.unitypackage) and other belongs to Vuforia 5 SDK for Unity (Vuforia-unity-5-05. unity package) that can be found in specified package that is folder.

Now, add some 3D model to the project. After that proceed go to

·  “Window->Asset Store”. In the above example, we can find Samurai model in the name of “Red Samurai”, free of cost. After that we will have to log into Unity Account and import the model.

Once it is imported to the file, our Folder will look like: -

Next, add an AR Camera to the file. “AR Camera is an Augmented camera from Vuforia and it is similar to the regular camera. It can be find under

· “Assets->Vuforia->Prefabs” and shifting to scene at X=0, Y=0, Z=0.

· We have to delete Main Camera from the scene found under Hierarchy Panel, “Right Click-> Delete” including AR Camera. To run, AR Camera, we have to add App License Key. In the Inspector panel, we have to paste the unique key that we have received from Vuforia’s License Manager.

Dismissal through Power Button

When we press power(hardware) button, it sends power key event. Therefore, we cannot use power button via back button or navigating generally. While pressing, power button, it returns to the user in home scree. For that, there are two exceptions:

· If the user is in IME, pressing the IME button it closes and return to the user in app

· If the user is using watch face, after pressing the hardware button opens the app launcher.

Now, when we press the pay button inside the Unity Editor, we can able to see webcam feed in Game view. Next, let us add Image Target to our scene. It can be found under “Asset->Vuforia->Prefabs. Now, add it to point at X=0, Y=50, Z=0. In inspector panel, for Image target we have to make some changes like “Data Set” convert to “Image_Target” and “Image target” to “stones_hires”. Then, stones_hires image appear in scene view.

Now, next drag shift Samurai onto the scene. It may be found under the tab Asset->prefab->samurai”. For samurai to appear onto the image target, it is required to be made of a child of Image Target. Then, when the Image is found by a mobile device camera, targeted children will appear together. Scale of the samurai should be X=0.5,Y=0.5,Z=0.5.

Now, comes to activate Image_Target Dataset. It can be done by selecting “ARCamera”. In inspector panel, under “Dataset Load Behaviour (Script)”, selecting “Load data Set Image_Target” and after that “Activate”.

Now, selecting the “Run” button and a print out of the image inside the webcam then we will see that, samurai on it and it is doing “Attack animation” that is the default animation.

We are almost done and the last step is to create project for Android. For that we have to go to “File->Build settings”. Adding the current scene by selecting “Add Current”. Then, selecting the platform (Android).

Final Result (Demo)

Finally, the app is built and it would be a magical. Once it happens, we can run on Android and we can use on mobile with animation. Below it is shows that how it looks like



Get Answers to your Programming Questions

Recommended Deals ends in

Quiz For You:

Search Tags