Preventing poor tracking

We've mentioned several times in this book that image targets, whether they be natural feature textures or user-captured images, should meet certain criteria in order to be effective recognizable targets. Characteristics include being rich in detail, having good contrast, and including no repetitive patterns. As developers, if we provide the targets to our users, we can make sure these requirements are met. With user-defined targets captured at runtime, it could be more of a problem.

Fortunately, Vuforia provides a feature that checks the viability of the video feed as a potential target. And we can listen in on these events to provide feedback to the user.

For this project, when the app is scanning and ready for the user to capture a target, we display a white circle along with the Capture button. What we'll do is show a red circle instead when the video feed is low quality for a target. Let's add that now:

  1. In Hierarchy, duplicate the AR Prompt Idle object (right-click | Duplicate).
  2. Rename it AR Prompt Error.
  3. Set its Color to red (#FF0000FF).

Add some help text:

  1. Create a child text, UI | Text.
  2. Anchor Presets: Stretch/Stretch, and Alt+click to center it.
  3. Paragraph Alignment: Middle, Center.
  4. Set its Text to say Target needs more detail.

Now we need to tie this in with the Vuforia event.

The Vuforia user-defined target behavior will use Unity events to signal when the current device camera view would be an acceptable target image or not. We can use these events (UserDefinedTargetEvent interface) as feedback to our users when the app is ready to capture a potential target image.

We can provide the UserDefinedTargetBuilder as a way to reference our AR Prompt Error by attaching the Quality Dialog component to it. This component is intended for a dialog box that might say The image has little detail, please try another, but we're going to use graphic feedback to the user instead of text.

  1. On the AR Prompt Error object, Add Component | Quality Dialog.

Now the UserDefinedTarget will automatically enable this object if there is an error with the image that was captured.

To dismiss the red circle, we have to do that ourselves.

  1. On UserDefinedTarget, add another event handler for On Target Found() by pressing +.
  2. Drag the UserDefineTargetBuilder to the Object slot.
  3. For the function, choose UDTEventHandler | CloseQualityDialog().

The Trackable Object Visibility component dialog event settings will now look like this:

Save your work.

Now when you press Play, if you try to capture a poor target (like a blank wall), you'll see the red circle instead of the white one. When you press Capture on an acceptable target, then the AR content will appear.

Very good.

So just to recap, so far in the project:

  • We added an AR Mode button to the 2D UI that toggles the user to an AR view.
  • When AR mode is enabled, we hid the Main Canvas' Content Scroll View and started scanning for AR targets.
  • Behind the scroll view is the AR Prompt panel that contains a Capture Target button, a small cursor in the middle of the screen, and a white circle to guide the user to fit the view of his automobile tire in its circumference.
  • When the target is captured, the AR Prompt panel is disabled and the AR graphics are displayed. If the user tries to capture a poor target, we use the Vuforia Quality Dialog event to turn the prompt circle red.

Now it's time to use this AR mode to present graphic content to the user.

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

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