documentation

Poster Tracker Tutorial

Level: Basic

The following example project demonstrates the general usage of the plugin by setting up poster-based tracking.

Preparations

Connect a webcam to your computer to be able to test the tracking within the Unity Editor.

Download the VisionLib.SDK-Unity package from the customer area and make sure to have a valid license file at hand.

You will also need Unity 2019.4 LTS or higher (we recommend using 2019.4 LTS).

Example Project Setup

  • In a new Unity project, import the VisionLib.SDK-Unity.tgz via the package manager and add the VisionLib.SDK.Examples-Unity.unitypackage via Assets > Import Package > Custom Package.
  • Copy your license file to Assets/StreamingAssets/VisionLib.

Delete Main Camera and instantiate VLCamera

  • Delete the Main Camera from the Hierarchy.
  • Drag and drop the VLCamera prefab from the VisionLib SDK/Core/Prefabs/Camera directory into the Hierarchy.

Create a Tracking Configuration

  • Browse to StreamingAssets/VisionLib/Examples/PosterTracking, make a copy of the PosterTrackingConfiguration.vl and name it TutorialPosterConfiguration.

This tracking configuration file is used to describe a poster tracker. Inside this file, you will need to reference the image file path for the image or the poster you want to track (TutorialPoster.png in this example). For more information on the format of tracking configuration files, please refer to the documentation.

  • Copy your image to the StreamingAssets/VisionLib/Examples/PosterTracking folder of your project.
  • Change the imageURI parameter inside the configuration file from LeavesPoster.png to the filename of your own image (e.g. "TutorialPoster.png"). Retain project-dir: in front of the name.
  • Adjust the attribute realWidth according to the physical size of your poster in meters. The default value matches ISO A4 (210 mm x 297 mm).

Your tracking configuration file should now look similar to this:

{
"type": "VisionLibTrackerConfig",
"version": 1,
"meta": {
"name": "PosterTrackerTutorial",
"description": "Tracker for a reference image",
"author": "Visometry"
},
"tracker": {
"type": "posterTracker",
"version": 1,
"parameters": {
"imageURI": "project-dir:TutorialPoster.png",
"realWidth": 0.269, // Width of the reference image
"metric": "m"
}
}
}

Reference your Configuration File in the Scene

  • Create a new GameObject, name it VLTracking and add the component TrackingConfiguration to it.
  • Drag the tracking configuration file that you created above from the project view into the according inspector field of the component.
  • Also reference your license file here.
  • Afterwards, check the Auto Start Tracking option of the component to start the tracking automatically.

Populate your Scene

  • Next, drag any object into your scene, e.g. a simple cube.
  • Adjust the object's scaling so it will fit to the poster's size.

The scene will be rendered at the point where the tracked poster is located, so it is wise to place your objects close to and above the origin (0|0|0) of the coordinate system in order to be able to see your scene.

Execute your setup

Run your project by entering the Play mode. Print the poster and put it on the table or display it on a monitor. Point the camera on it. As soon as VisionLib has detected the poster, you should see the cube augmented on it in Unity. Try different positions and angles if VisionLib doesn't recognize the poster immediately.