Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Spatial Anchors allow you to place virtual object in a specific point in your real world. You can think of them as more accurate GPS that works indoors as well as outdoors. Spatial Anchors are available for iOS, Android mobile devices and HoloLens headsets. Azure Spatial Anchors gives you a way to save and share anchor points, so that you can share the virtual objects or information between multiple devices and persist them over time.
Short link: aka.ms/AzureSpatialAnchorsLesson
In this class, we will learn about creating a Mixed Reality Application using Spatial Anchors and Mixed Reality Toolkit.
How to integrate ARCore for Android?
In this lesson, you will learn about Spatial Anchors and the use case scenarios of Spatial Anchors:
To share Azure Spatial Anchors, SDK translate the local Spatial Anchor data into Azure Spatial Anchor format and saves it. Similarly, when a different platform asks for the same Spatial anchor data, the device will receive the anchor in the platform's format.
Using Azure Spatial Anchors allows you to share any information in specific context, time and space. Some of the use cases are having user guides for machinery, inventory information, way-finding applications, educational applications, multi-player games. The evolution of smartphones and near-universal access to the GPS data changed the apps we build and enabled ride-sharing and location- based recommendation applications. Developing with Azure Spatial Anchors will help you deliver contextual data at the right time and place. It will open up new possibilities indoors.
By using anchor relationships, you can create connected anchors in a space and then ask questions like these:
Are there anchors nearby?
How far away are they?
You could use connected anchors in cases like these:
A worker needs to complete a task that involves visiting various locations in an industrial factory. The factory has spatial anchors at each location. A HoloLens or mobile app helps guide the worker from one location to the next. The app first asks for the nearby spatial anchors; it then guides the worker to the next location. The app visually shows the general direction and distance to the next location.
A museum creates spatial anchors at public displays. Together, these anchors form a one-hour tour of the museum's essential public displays. At a public display, visitors can open the museum's mixed reality app on their mobile device. Then, they point their phone camera around the space to see the general direction and distance to the other public displays on the tour. As a user walks toward a public display, the app updates the general direction and distance to help guide the user.
When creating or locating anchors, pictures of the environment are processed on the device into a derived format. This derived format is transmitted to and stored on the service.
To provide transparency, below is an image of an environment and the derived sparse point cloud. The point cloud shows the geometric representation of the environment that is transmitted and stored on the service. For each point in the sparse point cloud, we transmit and store a hash of the visual characteristics of that point. The hash is derived from, but does not contain, any pixel data.
Start your project from UnitySeedProject.
Work on main scene or create a new scene and configure your scene with MRTK.
In the Publishing Settings Configuration section, check InternetClientServer and SpatialPerception.
Add Spatial Mapping Collider component to your camera.
When working with Unity, all Unity APIs, for example APIs you use to do UI updates, need to happen on the main thread. In the code we'll write however, we get callbacks on other threads. We want to update UI in these callbacks, so we need a way to go from a side thread onto the main thread. To execute code on the main thread from a side thread, we'll use the dispatcher pattern.
Let's add a member variable, dispatchQueue, which is a Queue of Actions. We will push Actions onto the queue, and then dequeue and run the Actions on the main thread.
Next, let's add method to add an Action to the Queue. Add QueueOnUpdate()
right after Update()
:
Let's now use the Update() loop to check if there is an Action queued. If so, we will dequeue the action and run it.
Attach a local Azure Spatial Anchor to the sphere that we're placing in the real world.
Add task.run function on line 26 to your CreateAndSaveAnchor function. We will change the color of the sphere to indicate that it is saved or failed to save.
At this point, your AzureSpatialAnchorsScript.cs should look like below code snippet:
Now you can follow the build tutorial for HoloLens and start creating anchors in your environment.
How to integrate ARCore for Android?
Go to Azure Portal: portal.azure.com.
In the left navigation pane in the Azure portal, select Create a resource.
Use the search box to search for Spatial Anchors.
Select Spatial Anchors. In the dialog box, select Create.
In the Spatial Anchors Account dialog box:
Enter a unique resource name, using regular alphanumeric characters.
Select the subscription that you want to attach the resource to.
Create a resource group by selecting Create new. Name it myResourceGroup and select OK. A resource group is a logical container into which Azure resources like web apps, databases, and storage accounts are deployed and managed. For example, you can choose to delete the entire resource group in one simple step later.
Select a location (region) in which to place the resource.
Select New to begin creating the resource.
After the resource is created, Azure Portal will show that your deployment is complete. Click Go to resource.
Then, you can view the resource properties. Copy the resource's Account ID value into a text editor because you'll need it later.
Under Settings, select Key. Copy the Primary key value into a text editor. This value is the Account Key
. You'll need it later.
Go to Azure For Students page: bit.ly/AzureStudentCredit or scan the below QR code.
Follow the Activate Now link to sign up.
Scroll down to assets section and click on AzureSpatialAnchors.unitypackage to download.
In your Unity project select Assets > Import package > custom package and find the downloaded AzureSpatialAnchors.unitypackage and import all.
Import AzureSpacialAnchors asset into your script.
Add the CloudSpatialAnchorSession and CloudSpatialAnchor member variables into your AzureSpatialAnchorsScript
class:
Initialize Session:
Add methods to handle delegate calls.
Call the InitializeSession() method inside the Start() function:
Yes, if you build you can prevent that from happening. You can implement Authentication in your application and check for permission before you respond to an API call for Anchors. Read more...
Lighting, people moving arround and the changing environment can reduce the retreivability of the anchors. Finding contrasting colored an unchanged object and starting the session from there would be helpful.
You can retreive a nearby anchor and ask for the other anchors in a radius.
You can store your Spatial Cloud Anchors as local anchors in your device.
Code Samples: https://aka.ms/MixedRealityUnitySamples
Azure Spatial Anchors Documentation: bit.ly/AzureSpatialAnchors
Azure Spatial Anchors API: bit.ly/asa-api
ASA Samples Repo: bit.ly/AzureSpatialAnchorsSamples
ASA SDK Releases: bit.ly/ASAReleases
Sign in to your Azure Portal
Create a resource by selecting Databases > Azure CosmosDB
Select the subscription and resource group you are using for this project.
Enter a unique name to identify Azure Cosmos DB account.
Select "Azure Table" as the API.
Select a geographic location to host your Azure Cosmos DB account. Use the location that's closest to your users to give them the fastest access to data.
You can leave the Geo-Redundancy and Multi-region Writes options at their default values (Disable) to avoid additional RU charges. You can skip the Network and Tags sections.
Select Review+Create. After the validation is complete, select Create to create the account.
It takes a few minutes to create the account. You'll see a message that states Your deployment is underway. Wait for the deployment to finish and then select Go to resource.
Copy the Connection String
for later use.
Open SharingService\Startup.cs.
Locate #define INMEMORY_DEMO
at the top of the file and comment that line out. Save the file.
Open SharingService\appsettings.json
.
Locate the StorageConnectionString
property, and set the value to be the same as the Connection String
value.
Create a new script called AzureSpatialAnchorsScript.
Add imports:
Add the following members variables into your AzureSpatialAnchorsScript class:
After you run your application, you can check to see the recently created anchors by navigating to the Azure Portal > Spatial Anchor resource you have created for this tutorial.