My first experiment with Augmented Reality (AR)
Android ONE is the first Augmented Reality Application which I am going to create here.
Following steps are required to create AR application and further create the Android APK to run it as application on Android phone. Similarly, this can be run on IOS.
- Create Vuforia account. (https://developer.vuforia.com/)
- Create License Key for the AR app
- Upload an Image as Image Target
- Understand Vuforia Image Recognition system
- Download Unity Hub setup.
- Place 3D Model (Unity) on top of Image Target
- Test image on Android device
Step1: Create Vuforia account
To get started, we will need to go to Vuforia’s Developer Portal and create an account.
- If you don’t have a registered account, register with your email_id and password and account activation link would be sent to your registered email address. Hurray Vuforia account is created.
Step2: Create Vuforia account
- To use Vuforia with Unity, we will need to do two things:
- A license key is a unique ID which is required to create an app in Unity which uses Vuforia. To create a license key, we need to head over to “Develop >> License Manager >> Get Development Key” and select “Add License Key”.
Following screen will appear:
Here you can give your application name and confirm, for instance:
On click on Confirm button, it takes you to License Manager Screen as shown below:
The very next step is to select your application, Hurray License key is generated 😊
Step3: Create a Database and an Image Target
The next step is to set up an image as a target. We head over to “Develop >> Target Manager” and select “Add Database” and fill in the details:
Following screen appears, give any name to Database for instance AndroidDB and select Device and create:
Once the Database is created, we need to add the Target:
Step4: Understand Vuforia Image Recognition system
Here Target is the image Target (JPEG/PNG) which is the base for 3D model we are going to use in Unity. Make sure you provide width as well to add the Target to the Database. An important thing to note here is the “Rating”. A good rating means that the Image can be used for tracking, whereas a bad rating means that the image does not have enough feature points.
We can also have a look at the feature of our image by selecting “Image >> Show features”
Now we will download the dataset by selecting “Download Dataset >> Unity editor”.
Select Unity Editor and Download and copy this AR Database to your Desktop.
Step5: Download Unity Hub setup
Use the following link to Download Unity Hub, make sure you down Android Support SDK and JAVA JDK along with this. Make sure you download the latest version.
Step6: Place 3D Model (Unity) on top of Image Target
Let’s start by creating a new Unity3D project by the name of “AndroidONE”.
Once you open the new project in Unity 3D, following screen appears:
Right click on the Main Camera and delete this as we cannot use Main Camera for AR application. Save the project.
Add the AR camera as shown below:
In the next step, we need to provide License Key to AR camera being generated in Vuforia account.
Click on the AR Camera, and open Vuforia Engine Configuration:
Pass the License key in App License key and click on Add License:
In the next step, we will add the Image Target being created in Vuforia to Unity 3D.
Import the Image Target being downloaded from Vuforia to Unity 3D. Just drag the Vuforia Image Target and place it on Unity 3D assets.
Following screen will appear:
Now go to Image Target>>Inspector>>Database>>Select Database created in Vuforia.
Image will be shown in the Scene tab, we selected in Vuforia.
Now we will place 3D model on the Image Target, using Asset store of Unity 3D.
Select any 3D model of your choice, as shown below:
I have selected Barbarian, and downloaded to My Assets, which now can be imported in Unity 3D model.
Once imported, this will be available in the Assets folder
Now drag this 3D model on the Image Target:
Make sure the 3D model is under Image Target as shown below:
Select the database created in Vuforia in dropdown list:
On click of play, now you should be able to have your custom image and 3D model over it.
Step7: Test image on Android device
Make sure the Android SDK and JAVA SDK is downloaded along with Unity 3D package. Once done
Goto File>>Build Settings>>Player Settings
Make sure, Virtual Augmented Reality Supported checkbox is selected.
Click on the Switch Platform button and click on the Build button.
This APK file further can be installed on Android phone and executed.
Video is attached.
Once this APK file is downloaded, it can be installed on the android device via Bluetooth or USB transfer. Post this go to the application and focus the camera on the Image Database, screen-shot is attached.
Finally, the magical part!
Once the app builds and runs on Android we can point the mobile device’s camera to the Image marker and watch the animation.
Lots of amazing stuff can be built using Unity and Vuforia. In this blog, we have made a simple AR application with animation without writing a script!
Advantages of Augmented Reality in Real time:
- Unique User-Experience
- Improved graphical information
- Easy Visualization
- Improved Brand Awareness and Image