Preparing the image target

First import the business card image into your project (for example, drag and drop it into your Project Assets folder).

When you installed ARToolkit in Chapter 2, Setting Up Your System, we downloaded the Unity asset package. We also downloaded Additional Unity Tools (as a ZIP file) and installed them in a Programs folder (or Applications folder) or somewhere you can find them now. We are going to use the genTextData program, a command-line tool.

ARToolkit offers several types of targets including images (which they refer to as natural feature tracking, or NFT), and then they have square markers, kind of like QR codes, which are black and white markers that have a significant border around them. For this project, we're using the NFT.

Basically, we want to run the genTextData command giving the image file as an argument.

On Windows, you can take the following steps:

  1. Using File Explorer, open the folder containing the image file (in our case, PurpleFinchCard.jpg). Actually, you may want to copy the image into a separate working directory as we will be generating additional data files to go with it.
  2. Using another File Explorer window, navigate to your installed ARToolkit tools. On Windows this might be C:Program Files (x86)ARToolKit5in, and open the bin directory.

 

  1. Find the application named genTextData.
  2. Launch the Windows Command Prompt (right-click Start | Command Prompt). (On Mac, open a Terminal window).
  3. Drag the genTextData program from the bin to the terminal.
  4. Press the spacebar.
  5. Then drag the image file from its folder to the terminal.

Isn't Window's nice to take care of all that typing for you?! Press Enter to run the command.

Next you are requested to provide the levels of extraction, or image resolutions, for feature tracking. In ARToolkit you specify a maximum and minimum resolution. The level of extraction are the in-between resolutions.

Resolution is in terms of dots per inch (DPI). Our original PurpleFinchCard.jpg image is 1796 x 1024 pixels, and the physical card is 3.5 inches by 2 inches. So, the max resolution we can match against is 512 DPI. Regardless of how much resolution is in the device camera at runtime, the matching can't be more accurate than the target image. But if the runtime camera is moved away from the card, we want to try and match against less pixels. As shown in the following list, the program suggests a min and max image resolution of 65.597 and 2399.000; we will use the min 66 and max 512:

  1. Select extraction level for tracking features: Choose the default, 2.
  2. Select extraction level for initializing features: Choose the default, 1.
  3. Enter the minimum image resolution: Enter 66.
  4. Enter the maximum image resolution: Enter 512.

It then generates the dataset for the image tracking. The data is crunched and data files are generated (.fset, .fset3, .iset) in the same directory as the given image.

A terminal session for genTexData.exe is shown in the following screenshot:

Now in Unity, import the image data into the Project Assets/StreamingAssets folder. The easy way to do this is select the files from your Explorer (Find) window and drag them directly into Unity. You can (and should) omit the original JPG file.

All the files in your StreamingAssets folder will be built into your final app. Delete any unused files, including the original image used to generate the target data, and any sample images that might have been imported with your samples package.
..................Content has been hidden....................

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