Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
How Anchors work?
3.
Types of Anchors
3.1.
Image anchor
3.2.
Plane anchors
3.3.
Face anchors
3.4.
3-D object anchors
4.
How Trackables work?
4.1.
createAnchor
4.2.
getAnchors
4.3.
getTrackingState
5.
Frequently Asked Questions
5.1.
What is the difference between the anchor and trackable?
5.2.
What is augmented reality or AR?
5.3.
How does AR vary from VR?
5.4.
Name some of the examples of AR applications in real life?
5.5.
What are AR cloud anchors?
6.
Conclusion
Last Updated: Mar 27, 2024

Anchors and Trackables

Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

One of the essential concepts when building augmented reality (AR) experiences is to understand working with "anchors." In VR, the user does not experience the real world, so the developer can "place" the learner in any virtual location to begin the experience. With AR, the learner can experience the real world through or in the device display. The software platform and the device have to recognize something in the real world and then build the experience around that. An Anchor is used to trigger such an experience. Hence, they become one of the most significant differences between augmented reality and Virtual Reality (VR).

In AR Foundation, a "trackable" is anything that can be tracked and detected in the real world. Planes, environment probes, point clouds, anchors, faces, images, and 3D objects are all examples of trackable.

How Anchors work?

Firstly, let us review poses and world space.

World space

  1. It refers to the coordinate space in which the camera and objects are positioned
  2. The camera and object positions are updated in world space from frame to frame
     

Pose

  1. It represents an object's orientation and position in world space
  2. It is also referred to as a transform in iOS
     

When we create an anchor, we utilize a pose that describes an orientation and position relative to the world space estimate for the current frame.

We connect one or more objects to this Anchor. The Anchor and the objects connected appear to stay where they are positioned in the world. As the anchor pose adjusts to world space updates in each frame, the Anchor updates the object's postures accordingly.

We can attach multiple objects to the same Anchor to ensure that these objects maintain their relative position and orientation, even when the Anchor's pose adjusts.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Types of Anchors

Let us explore each of the anchor types briefly:

Image anchor

The image anchor is typically the most used type. This anchor lets you associate an image with the real world. The image could be a magazine advertisement, a billboard, or a printed sign in our office. The image must give enough detail to be recognizable: logos, text, distinct patterns, images, or anything else that will help your photo stand out. After the camera scans the image, the AR experience shows up on or around the image. The experience even moves with the image.

Image anchor (Image source)

Plane anchors

There are three types of plane anchors: horizontal plane, vertical plane, and mid-air plane. These anchors scan for a plane (wall or ground). Once that plane is located, the camera will create the AR experience on it. This would build a birds-eye view of a world that the user can explore, or it could allow the user to set objects in the real world, as done by the Ikea and Amazon apps.

Using a plane anchor (Image source)

Face anchors

Another standard anchor in AR is the face anchor or face tracker.  These tools use the person's face as the tracker to build the experience around the face. This is commonly used with social media filters and Apple's MeMoji features.

Face anchors (Image source)

3-D object anchors

This anchor lets the platform detect a 3-D object in the real world and build the experience around that 3-D object. There are 2 steps when working with objects. Firstly, scan the object using some scanner app. At last, import the scanned object into the tool. The authoring environment will provide the developer with the object's dimensions, but placing the experience around the object may require some testing. 

Using a 3d anchor (Image source)

How Trackables work?

A Trackable is something that ARCore can track and that Anchors can be attached to. The public methods for creating a trackable are:

createAnchor

public abstract Anchor createAnchor(
  Pose pose
)

 

It creates an anchor at the given pose in the world coordinate space that is attached to this trackable. The type of trackable will determine the semantics of attachment and how the anchor's pose will be updated to maintain this relationship. 

getAnchors

public abstract Collection<Anchor> getAnchors()

 

It gets the Anchors attached to this trackable.

getTrackingState

public abstract TrackingState getTrackingState()

 

It gets the TrackingState of this Trackable.

Frequently Asked Questions

What is the difference between the anchor and trackable?

Trackable is something that ARCore can track and Anchor can be attached to while an anchor is something that can hold for you a 3D geometry at its position in space.

What is augmented reality or AR?

Augmented reality (AR) can augment your surroundings by adding digital elements to a live view. It is mostly done by using a camera on a smartphone.

How does AR vary from VR?

Augmented Reality utilizes a real-world setting while VR is completely virtual. 

Name some of the examples of AR applications in real life?

Google street view, Pokemon Go, Snapchat, and Microsoft Hololens are some of the examples of AR applications in real life.

What are AR cloud anchors?

Cloud Anchors are anchors that are hosted on the ARCore Cloud Anchor API. This hosting allows users to share experiences in the same app. The basic guidelines for anchors is also applicable to Cloud Anchors.

Conclusion

In this article we talked about the basics of anchors and trackable along with their usage and types as used in the augmented reality industry.

Once you are done with this, you may check out our Interview Preparation Course to level up your programming journey and get placed at your dream company. 

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, System Design, JavaScript, etc. Enroll in our courses, refer to the mock test and problems available, interview puzzles, and look at the interview bundle and interview experiences for placement preparations.

We hope that this blog has helped you increase your knowledge regarding AWS CloudWatch, and if you liked this blog, check other links. Do upvote our blog to help other ninjas grow. Happy Coding!"

Previous article
Environmental understanding: feature points and surface detection
Next article
Augmented Images
Live masterclass