Shared Anchors
A shared anchor is a point in space that lets you share an AR experience with people around you, or enables persistent AR content. Each user who wishes to participate in a shared experience needs to find the same shared anchor. Once users have found a shared anchor, they can share virtual objects with other users. These shared virtual objects will appear at the same physical location.
This concept is used during the relocalization process (see Concept of Relocalization), where the SDK attempts to recognize a location. In the AR Cloud Tracking API, a shared anchor is associated with either an image or a map. Each image contains one shared anchor, and each map contains one shared anchor. In both cases, the shared anchor represents the origin of the coordinate system after the relocalization process is done.
Please note that when a shared anchor is found, due to the change in a coordinate system, any existing virtual object not attached to a local anchor will appear to “jump” to a different location.
Image-based Shared Anchors
The simplest form of a shared anchor is an image, like a poster or a picture printed on paper. In order to use an image as a shared anchor, the image needs to be preloaded in a database. A shared anchor is automatically created at the center of each image and will be used when the relocalization process is started and the image is located by the camera.
The steps to use an image as a shared anchor are as follows:
During the app creation
- Create an image database containing one or multiple images
- Enable the image-based shared anchor option in the app configuration
At runtime
- Select which images to use as a shared anchor (or set all images as shared anchors)
- Start the shared anchor relocalization process and look for an image
Once a user has detected the image by pointing their device at it, the system automatically uses the associated shared anchor to enable content sharing.
Please note that an image used as a shared anchor must remain static throughout the entire game session. If the image moves after users start to detect it, their coordinate systems will be desynchronized.
Additionally, any image in the database not set as a shared anchor can be used as a regular AR image to overlay virtual content. These images can be moved.
Map-based Shared Anchors
A map represents an area (for example, a room, a street, etc.) that has been mapped previously using Pretia 3D scanner app. The scanner app collects information about the area, creates a shared anchor at a specific location within the map, and stores all of this information into a server. An application created with the Pretia Tracking SDK can then request the server to start the shared anchor relocalization process using a specific map.
During this relocalization process, the user needs to point their device around them until the system has recognized the area. At this point, the shared anchor associated with the map has been found, and the user can start sharing content.
Workflow of finding a shared anchor on the server
The relocalization process would be three parts
Step 1: Initialization,
INITIALIZING
- Set the key corresponding to the map to use
- Start the relocalization process (find a shared anchor)
Step 2: Relocalizing,
FINDING SHARED ANCHOR
- Look around with the camera, the device will start sending data to the server regularly
- At some point, the server will match the device data with the map
- At this point, the device will update its coordinate system and you can start sharing content
Step 3: Relocalized,
SHARED ANCHOR FOUND
- After this, the device will continue sending data occasionally to the server to improve the relocalization