Configuring the AR for glasses

This step is an important one so that we understand how the glasses work.

If, at this point, we compile the app in the Moverio glasses, we will see the video feed over the glasses screens, as if we were using a phone. This is not the best way of working with AR; what we want is for the background to remain transparent and only the UI elements and AR elements appear over the screens.

However, to see the effect and some characteristics of the AR in the glasses, we are going to compile the app and then make the relevant modifications.

Turn on the Moverio glasses and connect them to your computer via USB.

As you have already defined the settings, switched the platform to Android, and added the current scene to the building list in the introduction, just click Ctrl + B or click on File|Build And Run (if you skipped any of these steps, or if you are not sure, go to File|Build Settingsā€¦ and check if everything is correct). Give the .apk file a name and build it.

As we've discussed, you will see the video feed on your glasses, and the UI will be larger than expected. For now, forget about the UI and take a look at the video feed. If you compare the video feed to the real-world image behind it, you will see that the video feed is smaller and slightly displaced compared to the real world (take into account that the camera is placed on one side of the glasses). The following image shows this displacement (take into account the picture is taken only from the left screen of the glasses, so the displacement is even greater than when the left- and right-hand sides are combined):

The AR view from the glasses

We have to take this into account because when we take the video feed out, the AR elements will look smaller and displaced on the targets.

So, first of all, let's take the video feedback. This is a very easy step in Vuforia as in the latest versions, they have taken it out from the code and placed it as a checkbox in the Vuforia Engine configuration. Follow these steps to do so:

  1. Select the ARCamera and in the Inspector window, click on Open Vuforia Engine configuration.
  2. In the Video Background component, uncheck Enable video background:

Disabling the video feed in the Vuforia Engine configuration
  1. And that's it! Build the app again by pressing Ctrl + B and you will see how the video doesn't appear this time and that when you point at the side target with the glasses, only the AR element is shown. You will also see how, without the video feed, the UI will be of the correct size.
Before the Video Background component, there is also a Digital Eyewear component. In the beginning, when Vuforia first enabled the AR glasses, the configuration of the scene went through this component. However, now, it is only valuable for HoloLens users to select the configuration for those glasses.
  1. Finally, let's make the AR elements match the real elements that can be seen through the glasses. Unfortunately, at the moment, there is not an exact method to do this. Therefore, we will take the displacement and size parameters out by trial and error and apply them to the rest of the elements. For this project, those values are as follows:
  • Displacement: +0.5f in the x axis
  • Scale: *2.5 in all axes

Instead of applying them one by one, create a new script called GlassesHandler.cs in your @MyAssets/Scripts folder and open it in Visual Studio. Add the following lines inside the Start() method:

foreach (Transform child in transform)
{
Vector3 scale = child.localScale;
scale *= 2.5f;
child.localScale = scale;

Vector3 position = child.position;
position += new Vector3(0.5f, 0, 0);
child.position = position;
}
Position, rotation, and scale parameters can't be added directly; an intermediate variable has to be used instead.

Your code should look like this:

GlassesHandler script in Visual Studio
  1. Drag this script to the three targets or add it by selecting each target, pressing Add Component in the Inspector window, and selecting the script.
  2. Press Ctrl + B to build your app and see how the elements now appear over the real elements.

To finish our app, we will add the PDF functionality to help the operator with their work.

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

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