Marker Tracking
Lens Studio’s Marker Tracking gives you the ability to a Lens which tracks content to a unique physical image. Marker Tracking is ideal for Lenses which are meant to be used in the presence of a custom image. For example, you can create a Lens that places an animated 3D character overlaid on a poster or mural of your own design. You can also set up a Marker Tracking Lens to detect and track Snapcodes.
This guide covers how to create a custom tracking Marker and include it in a Lens.
Creating a Marker Tracking Lens
This section covers how to create a Marker Tracking Lens in a new project. You can also follow these steps to add Marker Tracking to an existing Lens.
The quickest and easiest way to create a Marker Tracking Lens is to use Lens Studio’s Marker Template. To learn more about how to use this template, visit the Marker Template guide.
Prepare an Image for Tracking
If you're planning to use a custom image as a tracking marker, keep the following guidelines in mind to make sure that it will have smooth and accurate tracking:
- Make sure your image has a lot of detail and contrast
- Avoid repetitive patterns
- Avoid low resolution images
- Use a
PNG
orJPG
with a resolution of 2048 x 2048 or less
Here are some examples of bad markers:
Here are some examples of good markers:
Create a New Project
Create a new project by selecting File -> New Project
from the Lens Studio menu.
Alternatively, you can select New Project
from the Lens Studio launcher.
Create a Marker Tracking Object
Marker Tracking requires a Marker Tracking object to be added to your Scene. Your Lens can use either Image Tracking or Snapcode Tracking.
Adding Image Tracking
To set up your Lens to track a custom Image:
-
In the
Objects
panel, select+ -> Marker Tracking -> Image Tracking
-
Select a custom image file from your computer and select
Open
-
In the
Objects
panel, you should now see anImage Tracking
object parented to your mainCamera
object -
In the
Resources
panel, you should now see anTracking Marker
resource -
Select the newly created
Tracking Marker
resource in theResources
panel -
In the
Inspector
panel, note theMarker Height
field. You should set it to match the expected vertical size of the physical image, in centimeters (cm). For example, if you are planning to create a Lens which tracks content to a printed sticker that’s 8 cm in the vertical dimension, you should set your Image Marker’sMarker Height
to 8.0.
Adding Snapcode Tracking
-
In the
Objects
panel, select+ -> Marker Tracking -> Snapcode Tracking
-
In the
Objects
panel, you should now see aSnapcode Tracking
object parented to your mainCamera
object -
In the
Resources
panel, you should now see aSnapcode Marker
resource -
Select the newly created
Snapcode Marker
resource in theResources
panel -
In the
Inspector
, note theMarker Height
field. You should set it to match the expected vertical size of the physical Snapcode, in centimeters (cm). For example, if you are planning to create a Lens which tracks content to a printed sticker that’s 8 cm in the vertical dimension, you should set your Snapcode Marker’sMarker Height
to 8.0.
Image Tracking and Snapcode Tracking objects must be parented to your Scene's main Camera in order to track properly.
You can include up to 10 Marker images in a Lens, as well as a Snapcode Tracking objects to your Scene. For image tracking, only one image will be tracked at a time. For Snapcode tracking, only one Snapcode will be tracked at a time. That said, a single image and a single Snapcode can be tracked at the same time.
Orienting the Marker Tracking Object
The Marker Tracking object you created should be oriented in Lens Studio to match the expected orientation of the physical marker.
For example, if you expect users of your Lens to encounter the tracking marker on a horizontal surface, like a table, the Marker Tracking object should be oriented horizontally.
If, however, you expect users of your Lens to encounter the tracking marker on a vertical surface, like a wall, the Marker Tracking object should be oriented vertically.
By default, the Marker Tracking object is created in a vertical orientation.
Placing Content
Any content you want to track to your marker should already be imported to your Scene and set up as a Scene Object. This Scene Object should be parented to the Marker Tracking Object you created in the previous section.
To set up your content:
-
In the
Objects
panel, select the Scene Object you want to track to the Marker -
Click and drag the Scene Object so that it’s parented underneath the
Marker Tracking
object you created -
In the
Scene
panel, align the Scene Object’s position with the position of theMarker Tracking
object -
Scale the Scene Object as you see fit. Remember that the
Marker Height
property you set on the Marker resource represents the size in centimeters in physical space. You can use its size as a relative guide for scaling your content
To learn more about importing 2D and 3D content to your Scene, visit the Lens Studio guide on Importing and Updating Resources.
Previewing The Lens
To properly preview your Marker Tracking Lens in the Preview
panel, you’ll need to import a video of your Marker. To import a video file from your computer:
-
Select the dropdown at the top of the
Preview
panel -
Select
+ From Files
at the bottom of the dropdown -
Find the video file and open it
-
In the
Preview
panel, select the video you just imported -
You should now see your video playing in the
Preview
panel. Your content should be aligned to the Marker when it’s on screen.
Additional Information
The Marker Template
The quickest and easiest way to create a Marker Tracking Lens is to use Lens Studio’s Marker Template. To learn more about how to use this template, visit the Marker Template guide.
Marker Resources
Marker Tracking requires a Marker resource. The Marker resource defines the target image the Lens should track, as well as is expected physical size. There are two types of Marker resources: Image Marker and Snapcode Marker.
While a Marker Resource is created automatically when you add an Image Tracking or Snapcode Tracking object to your Scene, you can also create one manually.
Creating an Image Marker Resource
If you want your Lens to track a specific image, you can create an Image Marker.
To create an Image Marker:
-
In the
Resources
Panel, select+ -> Image Marker
-
Select a custom image file you want to track from your computer and select
Open
-
Select the newly created
Image Marker
resource in theResources
panel -
In the Inspector, note the
Marker Height
field. You should set it to match the expected vertical size of the physical image, in centimeters (cm). For example, if you are planning to create a Lens which tracks content to a printed sticker that’s 8 cm in the vertical dimension, you should set your Image Marker’sMarker Height
to 8.0
Creating a Snapcode Marker Resource
If you want your Lens to track Snapcodes, you can create a Snapcode Marker.
To create a Snapcode Marker:
-
In the
Resources
Panel, select+ -> Snapcode Marker
-
Select the newly created
Snapcode Marker
resource in theResources
Panel -
In the
Inspector
, note theMarker Height
field. You should set it to match the expected vertical size of the physical image, in centimeters (cm). For example, if you are planning to create a Lens which tracks content to a printed Snapcode that’s 8 cm in the vertical dimension, you should set your Snapcode'sMarker Height
to 8.0
Printing a Marker Resource
For convenience, you can print your Marker for use in testing. To print your Marker:
-
Select your
Marker Resource
(Image or Snapcode) in theResources
panel -
In the
Inspector
panel, select thePrint
button