Model Tracking Tutorial
Note
Support: Android / iOS
Tips: Model Tracking currently does not support directly running on PC, please build it to Mobile platform (Android or iOS) for getting effect experience.
Part 1. Introduction
The Model Tracking of VOID AR provides accurate recognition and robust tracking to objects in the real world.
This feature supports a wide variety of objects, from toys, to vehicles, to medical and industrial equipment. It is capable of being widely used in the field of industry, marketing, medical, education, exhibition, etc.
- Video Tutorial
Follow our video tutorial to learn the detailed steps for developing Model Tracking in Unity.
Part 2. Reading Guidelines
This tutorial is mainly to introduce how to use VOID AR Model Tracking SDK for model tracking in the Unity environment.
We assume that readers have basic experience in app development and unity usage.
For more unity3d usage information, please visit the official website of unity3d documentation.
Part 3. Development Environment
You need to install and prepare your development environment as below before you start.
OS
: Windows 7 or higher (we recommend using Windows 10)Unity3D
: Unity 2017.1 or higherNote
We recommend using the version in the tutorial:
Unity 2018.4.0f1 LTS
VOID AR SDK
: Download VOID AR Model Tracking SDK3D model Example
: Download Car.zip, please unzip it after downloadPaper Model Resources
: You can download here, print and refer to the instructions to make a paper model.Mobile device
: Prepare 1 Android or iOS device (Android requires Snapdragon 820 or higher, and iOS requires iPhone 5s or higher).
Part 4. Implementation process
The implementation process is divided into four steps:
- Step 1. Create project.
- Step 2. Use the tool to generate the initial contour and initial data of the model.
- Step 3. Produce application, bind contour / initialize data / model.
- Step 4. Packaging to mobile devices, and you can recognize and track the preset 3D object.
Step 1. Create project
1.1 Open new Unity project
Open Unity with new project. Fill the Project name with “ModelTracking
”, and select the location, and click [ Create project ]
.
1.2 Import SDK
Select [ Assets ] -> [ Import Package ] -> [ Custom Package... ]
,import VOID AR Model Tracking SDK.
Select the downloaded SDK file (.unitypackage), and click [ Open ]
button.
Click [ Import ]
from the prompted window. It takes minutes during the import process.
If there is a prompt window of “API Update Required” interface, please click [ I Made a Backup, Go Ahead! ]
.
Step 2. Generate initialization data using the tool
Note
The tool needs to be used in the Windows environment. The OSX platform is not currently supported.
2.1 Open tool
Select [ Assets ] -> [ VoidAR ] -> [ Tool ]
, open the ModelTargetCreator scene.
2.2 Importing 3D models
Please select a directory to import 3D models.
Important
For detailed requirements of 3D models, please refer to Requirements and Limitations of Model Objects
For example, right-click Assets, click [ Import New Asset... ]
, select Car.obj
to import in the pop-up interface.
Note
After importing, select the model, and confirms that the "Read/Write Enabled" property is selected
.
2.3 Add the model to the scene
Select the model
,and drag it to the scene.
Select the “Car
”, and adjust its position to (0,0,0).
2.4 Adjust the scale of the model
Important
The size of the model should be the same as or close to the tracking object.
First, you need to adjust the scale of the model.
The length of the paper-car corresponding to Car.obj is 10 cm
. Create a cube as a reference (the default value of x, y, and z for the newly created Cube in Unity is 1m).
Right click the scene, select “3D Object
” from pop menu, and click [ Cube ]
.
Select the “Cube
”, and adjust its position to (0,0,0).
Select the"Car
", and adjust its scale to 1/10 of the Cube (X, Y, Z = 0.008, 0.008, 0.008).
Note
After the adjustment, right click the "Cube
", and click"[ Delete ]
"to delete the reference cube.
2.5 Adjust the position of the model
Important
Please adjust the model, do not adjust the Camera.
It is recommended that after adjustment the model should be equal to or lower than eye-level but should not be higher than it.
Select the Car model, adjust the "Position" and "Rotation"
.
When adjusting, please make sure that the model is in Camera view. During the adjustment, you can directly preview the effect through the Game window.
After adjustment, it shows as below:
2.6 Set the material of the model
Expand the [ Car ], select the default
, check the “Inspector” area, open "Material
" to set the material of the model.
Set Element 0 and select the material as RimMat
.
After setup, it shows as below:
2.7 Set output path
First select “Main Camera
”, then hold the mouse left button on “Car
” and drag it to the parameter of “Model 3D
”.
Next, set the output path in "Main Camera
".
Important
For the convenience of subsequent use, it is recommended to set the path in the "Assets directory in Unity project";
To avoid unusual situations, please do not choose a path with Chinese characters, and manually create the folder in the directory first.
Set Output Path
= "D:\unity\ModelTracking\Assets\InitData"
After setup, it shows as below:
2.8 Generate contours and data
Select [ File] -> [ Save ]
to save the scene.
Set the resolution of the Game window to "640 × 360
" (if you do not have the resolution, please add it manually first).
First click the [ Play ]
button, and then click [ CreateInitData ]
to generate the initial contour and initial data of the model.
After successful creation, cancel [ play ], "the initial contour (model name.png)
" and "the initial data (model name.bytes)
" will be generated in the directory.
Step 3. Produce application
3.1 Create a new scene
Select [ File ] -> [ New Scene ]
to create a new scene.
3.2 Delete Main Camera
Right click the "Main Camera
” from the scene, and select [ Delete ]
.
3.3 Drag the prefabs
Expand the directory [ Assets ] -> [ VoidAR ] -> [ Prefabs ]
, and drag the prefabs “ARCamera
” and “ModelTarget
” to the scene.
When you finish the process, it shows as below:
3.4 Add the model to the scene
Select the previously imported model
, and drag it into the scene.
Note
Note that the model be dragged here should be the original, unscaled, unpositioned, and unrotated one.
3.5 Bind data
Binding initialization contour
Expand [ ModelTarget ], select InitContour
, and open the Shader settings in the "Inspector" area on the right side, and click the [ Select ]
button.
In the pop-up interface, select the generated Car.png
to complete the setting.
Binding model
First select “ModelTarget
”, then hold the mouse left button on “Car
” and drag it into the “Virtual Object
” variable.
The binding of the virtual model for overlay display is completed.
Binding initialization data
Select ModelTarget
and open the Initial Data setting in the "Inspector" area on the right side. In the pop-up interface, select the generated Car.bytes
to complete the initialization data binding.
3.6 ARCamera Setup
Select “ARCamera
”, then hold the mouse left button on “ModelTarget
” and drag it to the parameter of “ModelTarget
”.
After setup, it shows as below:
3.7 Set App License Key
Open the website of Cloud platform to register an account, and login
.
Website Url:https://cloud.voidar.net
Go to the Cloud plaform, and click [ Create model tracking app ]
.
Click [ Create application ]
.
Fill in the AppId in the popup window, and click [ Save ]
.
Note
Since the AppId is unique, please setup your AppId here, such as "com.VOIDAR.ModelTracking"
Warning
Make sure that your AppId and Bundle Identifier must be the same. Otherwise, when you need to remove the watermark, it will not work properly.
After that, you will get your “AppKey
”.
Back to Unity, select ARCamera, and check the Inspector on the right side, and continue with the setup of “App License Key
”.
3.8 Set the start button
Note
Add "start button
" and click to trigger recognition.
Right click the scene, select "UI
" in the list, and click [ button ]
.
When you finish the process, it shows as below:
Select the Button, look up in the “Inspector
” area on the right side, and click "+
" under the On Click() event.
Select the “Button”, then hold the mouse left button on “ModelTarget
” and drag it to the parameter of “Object
”.
Click "No Function", select "ModelTargetBehaviour
" in the list, and click [ StartTracking () ]
.
When you finish the process, it shows as below:
Select "Button" and set the size and position of the button and anchor point. You can adjust it as needed, and the reference settings are as follows.
Expand [ Button ], select Text
, and adjust the text content and font size of the button.
3.9 Save Scene
Select [ File ] -> [ Save ]
, click for saving your setup.
Setup the name as “ModelTracking
”, and click [ save ]
button.
Step 4. Publishing Builds
Note
Model Tracking currently does not support directly running on PC, please build it to Mobile platform (Android or iOS) for getting effect experience.
Build Process includes Android
and iOS
.
4.1 Android
First, switch the PC platform to Android platform from [ File ] -> [ Build Settings... ]
.
Select Android tag, if the [ Switch Platform ] button is grey, you need to download the Unity Android Support
. Please click on the right side of the [ Open Download Page ]
button, download and install.
Click [ Switch Platform ]
button, switch the platform to Android.
After switch process, close the Build Settings interface first, and continue with packing.
Select [ Edit ] -> [ Preferences... ]
, setup the preferences parameters.
Select “External Tools
” option, setup Android SDK.
Note
If you do not have SDK, please click [ Download ]
from the interface, it will guide you to download from the prompted website.
Or you can also download from links below:
After the installation of SDK, you are able to setup their directory.
Select [ File ] -> [ Build Settings... ]
, and click [ Add Open Scenes ]
button to add current scene into the build area.
It shows as below:
Setup parameters
Click [ Player Settings... ]
button, check the “Inspector
” area, setup the parameters as below or as your needs.
Set Company
= "VOIDAR"Set Product Name
= "ModelTracking"Set Bundle Identifier
= "com.VOIDAR.ModelTracking" (The Bundle Identifier must be as same as the AppId you setup in 3.7. Otherwise, when you need to remove the watermark, it will not work properly.)-
Important
Cancel the selection of “Multithreaded Rendering” !
Set screen orientation
Set Orientation
= "Portrait" or "Landscape Left"
Finish the settings, and click [ Build ]
button.
Set the file name as “ModelTracking
”, and click [ save ]
button to start building.
It takes minutes while building, please wait...
When the build is done, it will generate an apk file “ModelTracking.apk
”.
Android Build is completed.
4.2 iOS
iOS Build requires Mac device ( such as MacBook Pro、MacBook、iMac、Mac mini etc. )
Switch the platform to iOS platform in Unity, and build Xcode project.
Warning
It is recommended to use Mac device to build Xcode project. If previously you make the project in Windows environment, you can export the Unity project as a unitypackage, or copy it to Mac device and build for xcode project.
Launch Unity and open
the saved or copied project
. ( Skip this step if project opened already )
Switch to iOS platform in Unity, click [ File ] -> [ Build Settings... ]
.
Select iOS tag, if the [ Switch Platform ] button is grey, you need to download the Unity iOS Support
. Please click on the right side of the [ Open Download Page ]
button, download and install.
Click [ Switch Platform ]
button, switch the platform to iOS.
Click [ Player Settings... ]
button after switch.
Important
Cancel the selection of “Multithreaded Rendering”!
Set screen orientation
Set Orientation
= "Portrait" or "Landscape Left"
Select [ File ] -> [ Build Settings... ]
, click [ Add Open Scenes ]
button to add current scene into the build area.
It shows as below:
Finish the settings, and click [ Build ]
button.
Set the project folder name “Output
”, and click [ Save ]
.
Open
the Xcode project.
Setup parameters
Filling in your configurations: your certificate, deployment target.
Click [ Unity-iPhone ]
on the left side, config the parameters as below or by your customization:
Display Name
= "VOIDAR_Test"Bundle Identifier
= "com.VOIDAR.ModelTracking"(The Bundle Identifier must be as same as the AppId you setup in 3.7. Otherwise, when you need to remove the watermark, it will not work properly.)Version
= "1.0"Build
= “1.0”Team
= “Your Certificate”
Add Accelerate.framework
Select General tag and scroll down, click the "+
" in the "Linked Frameworks and Libraries".
Select “Accelerate.framework” from the prompted window, and click [ Add ]
.
After doing that, you will see “Accelerate.framework” from the list of "Linked Frameworks and Libraries" as below:
Add camera usage privacy
Select “Info” tag, click the "+" below the "Supported interface orientations". Select “Privacy - Camera Usage Description
” in the prompting list.
Set Enable Bitcode = “No”
Select ”Build Settings” tag, set Enable Bitcode = “No
”.
Cancel armv7
Select "Build Settings" tab, expand Architectures, and select "Other...
".
The pop-up interface, select "armv7" and click "-
".
After canceling, the display is as below.
Connect iphone or ipad to the Mac device, Click [ Run ]
.
After building, there will be an application “VOIDAR_Test
” built into your iphone or ipad.
The iOS build is done.
Part 5. Procedure of Use
After building, you can run it in your mobile device.
1) Launch the app, it shows as below.
2) Face the 3D object in the preset direction, and the recognition is successful.
By here, Model Tracking process is done.