Creating the targets

Vuforia offers two different options when working with images:

  • Device databases are groups of image targets that are created through the Vuforia Target Manager and then downloaded and included locally in the project.
  • Cloud recognition makes reference to the hosting and managing of the image targets groups directly online.

For this project, we will be using the first option. Databases, also known as datasets in the SDK, are groups of targets. They help with the classification of large amounts of targets, as well as memory and CPU usage. Databases can be dynamically loaded/unloaded at runtime and all the targets inside a loaded database will be added to the AR search. At the time of writing this book, there is no hard limit to the number of targets inside a database, although Vuforia recommends no more than 1,000 for performance reasons.

To create our own database and targets, we will have to log into the Vuforia development portal and head to the Target Manager, as shown in the following steps:

  1. Go to the Target Manager page at https://developer.vuforia.com/vui/develop/databases.
  2. Log In or Register (if you don't have an account) to enter the page:

 The Target Manager page
  1. Click on Add Database at the top right to create a new database. Because we will be using the Beetle images as targets, give the database the name Beetle

Creating a new database
  1. Now, click on the created database and click on Add Target.
  1. Click on the Browse button and select the Side.jpg image from the Targets folder of the project's resources. Once it's been uploaded, you will see that the Name field at the bottom will automatically be filled. Give it a Width value of 1 and click Add:

 

Creating a new target
  1. The target will automatically be created, and next to it, you will see a number of stars, as depicted in the following screenshot. These stars indicate how recognizable the image will be by the AR software. Four or five stars are good targets.
If you have any doubt or you want to know more about the other options that appear when you create a target, you can take a look at https://library.vuforia.com/articles/Solution/How-To-Work-with-Device-Databases.html.
  1. Repeat steps 4 and step 5 with the Back_closed.jpg and Back_open.jpg images and with the same Width of 1 so that all of them will have a similar scale in the Unity editor:
 The Target Manager page with the Beetle database and its targets
  1. Once the three targets have been created, click on Download Database (All), select Unity Editor, and click Download. It will download a Beetle.unitypackage file that we will import into the project.
  2. Double-click on the Beetle.unitypackage file to import it in Unity. You can also import it from the Unity editor by clicking on Assets|Import Package|Custom Packageā€¦ and selecting the file:
The target database files to be imported in Unity
  1. This will add the database to a newly created StreamingAssets/Vuforia folder and the compressed images of the three targets to the Editor/Vuforia/ImageTargetTextures/Beetle folder.

Now that we have the database included in our project, we are going to add the three targets to the scene by following these steps:

  1. Right-click on the Hierarchy window and click on Vuforia Engine|Image. This will create an ImageTarget object in our scene:

Adding a Vuforia ImageTarget to the scene
  1. By default, the ARCamera and ImageTarget will be in the same position and nothing will appear on camera. Using the Rotation tab, rotate the camera by 90 in the X axis and move it upwards 3 units until the target is in view:

ARCamera Transform values
  1. Create the other two ImageTargets and move them until the three are in view. Name them Target_Side, Target_Close, and Target_Open so that you can differentiate between them: 

The three targets in the scene
  1. By default, the ImageTarget represents the first target found in the first database, sorted alphabetically. To change it, select the Target_Side in the Hierarchy window, and in the Inspector window, under the Image Target Behavior component, select its image. Do the same with Target_Open. If you want, scale the targets up/down using the scale tab and move them until they look similar and take up all the camera width for a better view: 
Changing the image reference for the targets

We'll learn how to add test cubes in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.239.148