Unity

Integrating SolAR pipelines in Unity Engine gives opportunities to developers of AR services to get access to fully configurable SolAR-based solutions to design AR applications.

SolAR has now a Plugin for Unity

Install Unity

  • Refer to https://store.unity.com/download?ref=personal

  • Download the last version of Unity Hub. The hub gives you the possibility to get access to different versions of Unity.

  • Our current version (our tests are based on) is 2019.4.15f1

Create a new Unity project

  • New project

NewUnityProject

Interface to create a new Unity project

It’s recommended that you use a 3D project set-up.
If you are new to Unity, check online tutorials to help you.

SolAR Plugin for Unity

For whom ?

For users who want to simply design AR services: Choose a pipeline, configure it in the inspector, and experience AR at run-time.

Easy to use, understandable for everyone.

Download

This package provides user with the minimum requirements to load a SolAR pipeline in Unity and includes three pipelines (Fiducial marker, natural image marker, and a SLAM).

Project Structure

The plugin version will add the following hierarchy in the Assets folder of your unity project:

  • Plugins: Host the binaries of the SolAR Framework, of the the pipeline manager that will handle the load of SolAR pipelines as well as the relative third parties (boost and xpcf).

  • SolAR

    • Demos

      • Materials: Materials used to display the video stream of the camera in the background.

      • Objects: Some 3D objects to augment the scene.

      • Prefabs: All the prefabs required to simply use SolAR in Unity.

      • Scenes: Sample scenes for simply testing the SolAR plugin.

      • Scripts: UI-related scripts for the demo.

    • Editor: scripts to control the pipeline manager appearance in the Inspector and customize build process for various platforms.

    • Pipelines: The xml configuration files for the different SolAR pipelines. It is mandatory to put these pipeline configuration file in or under this folder.

    • Scripts: various script to be able to use SolAR pipelines in Unity.

      • Swig: C# wrapper classes to expose SolAR native API, generated from C++ with SWIG.

  • StreamingAssets

    • SolAR

      • Android: contains a file that lists all assets. Used by Android build to install app properly.

      • CameraCalibration: Some camera calibration files used by the pipelines handling their own camera.

      • FBOW: vocabulary files used by the SLAM pipeline.

      • Markers: files describing the markers. You can edit these files to provide the exact size of the markers defined in meters, or create them to add new markers.

How does the SolAR Plugin for Unity work ?

The SolAR plugin for Unity is a simple interface to load any SolAR pipelines assembled by the SolAR pipeline assemblers and use them to design AR services with Unity.

To load a SolAR pipeline in Unity, simply drag and drop the SolARPipelineLoader prefab (in SolAR/Prefabs/novice) in your scene hierarchy. The SolARPipelineLoader has the following parameters:

  • Camera: is the virtual camera whose position and orientation will be automatically updated at runtime according to the camera pose computed by the SolAR pipeline.

  • Use Unity Webcam: Check it if you want to replace the camera used by the pipeline by a Unity camera. If checked, you will be able to select a camera among those available on your computer. For a better experience, you can set the intrinsic parameters of the camera. For that, you will need to calibrate it (see Camera Calibration).

  • Custom_Canvas: For video see-through AR, the system has to display the video stream of the camera on background. If unchecked, a Canvas with the video stream of the selected camera will be automatically created when the application will start. If you want to manage your canvas by yourself, you can check this option and drag and drop your canvas and its material.

  • Select Pipeline Folder: A button to select the folder where the available SolAR pipelines are stored in your Unity project. These pipelines must be stored anywhere under the folder Assets/SolAR/Pipelines/.

Set your SolARPipelineLoader by dragging and dropping your main camera from your scene hierarchy to the Camera parameter in the SolARPipelineLoader inspector.

Then you can put any object in your scene hierarchy to visualize it in augmentation (you can drag and drop the SolAR can available in the SolAR objects). The camera will automatically move relatively to the coordinate system of your marker (positionned in the center of the marker, x-axis pointing to the left, y-axis pointing to the top, z-axis pointing backward), so place your object in (0,0,0) if you want it to be positionned in the center of your marker.

For each object with a renderer, add the TAG SolARObject to make it disappear when the pose provided by the pipeline is wrong.

Test SolAR pipelines

Simply load the sample scene Assets/SolAR/Demos/Scenes/NoviceVersion.

Now you can choose a SolAR pipeline among the fiducial, the natural image or the SLAM:

  • Select the SolARPipelineLoader object in your scene hierachy.

  • Select the PipelineFiducialMarker in the drop-down menu under the button Select Pipelines Folder.

You will see a list of parameters relative to the different components of the selected pipeline. A tooltip provides user with information relative to each parameter when he move the pointer over the parameter (only if the configuration file of the pipeline defines descriptions for the configuration parameters).

Finally, you can print the following fiducial marker, play the application, and present the marker in front of the camera. That’s it, you should visualize the SolAR robot appearing on your fiducial marker.

FiducialMarker

Now, stop the application, select the SolARPipelineLoader object in your scene hierarchy, and select the PipelineNaturalImageMarker. Print the following image marker, and play the application. Changing pipeline is as simple as that !

NaturalImageMarker

Finally, you can test the SLAM pipeline. To initialize the SLAM, you will need to target the fiducial maker with your camera. When it is done, the SolAR robot should appear. Here, as the SLAM pipeline build a 3D map to localize your camera, it does not matter if the fiducial marker does not remain in its field of view.

For a better AR experience, it is preferable to enter the actual size of the marker in meters. You can do it by editing the marker files available in the folder Assets/StreamingAssets/Markers/. By editing these files, you will also be able to change the fiducial marker pattern or the image of reference for the natural image marker pipeline.

Troubleshooting

I have selected another pipeline but the application still uses the old one

This might mean your selection hasn’t been saved. This is a known issue that remain to be fixed.

A workaround is to select a value in a pipeline parameter, erase it, write the same value again, and then save.

The camera viewport is blank on Android

When targetting Android, you MUST check the Use Unity Webcam box. Let the camera selected by default in the dropdown menu.