Skip to content

Unity AR demo using ViSP

Fabien Spindler edited this page Apr 6, 2020 · 8 revisions

1. Using ViSP Unity wrapper in Unity engine

This project contains in unityProject folder 2 demos that illustrate ViSP Unity wrapper usage. From here we suppose that you followed the previous tutorial that shows how to build ViSPUnity plugin that was installed in unityProject/Assets/ folder.

  • Start Unity engine and open $VISP_WS/unityProject
  • The generated ViSPUnity plugin should be visible in the Assets

  • 36h11 AprilTag can be downloaded from here.
  • In Assets > Scenes window you should see 2 scenes corresponding to AprilTag Augmented Reality demo and Generic Model-Based Tracking demo respectively

2. Unity demonstrations using ViSP

2.1. AprilTag Augmented Reality demo

For the first project, go to the folder Assets/Scenes and open scene_ar by double click.

  • You should have a similar Unity window opened, as shown below:

  • Click on the Plane GameObject in hierarchy and modify in the inspector window some demo settings:
    • The Tag_size value according to you printed tag size. This value corresponds to the dimension of the black square in meters.
    • Optionally you can also modify the values of your camera parameters obtained after camera calibration.
    • If you have more than one camera attached to your computer, use Camera_id to select the camera to use. We print some Logs in Console that may help to identify each camera id.
    • Note also the Debug_display option that is disabled by default. If enabled it will open a windows in which the current image is displayed with computer vision results that may be useful to understand the low level processing achieved with ViSP.

  • Notice that the gameObject Cube is a child of gameObject Cube_pivot. This is done to make sure that the cube rotates around the center of one of the faces.

  • The current implementation takes care of position, scaling and rotation of the cube. A small YouTube Video demonstration is also available here.

2.2. Generic Model-based Tracking demo

For the second project, go to the folder Assets/Scenes and open scene_mbt by double click.

  • You should have a similar Unity window opened, as shown below:

  • For this project demonstration, we are using a 12.5cm x 12.5cm x 12.5cm cube made from cardboard. An AprilTag (8cm x 8cm) is pasted on one of its faces for initialisation of tracker. Here is a photo for reference:

  • First, click on the 'Plane' GameObject in hierarchy and put in the values for your camera resolution, select the tracker type and select edges visibility in the inspector window:

  • Now, click play button to start. A small YouTube Video demonstration is also available here.
Clone this wiki locally