Skip to main content
Published
Jul 29, 2022
4y ago
Total Downloads
9.3K
9,346

Deprecated Package Version

Reason: Legacy

Please note, this package is obsolete as of 10/01/2025 and is no longer maintained or monitored. Refer to our deprecation policy (https://aka.ms/azsdk/support-policies) for more details.

Install

dotnet add package Azure.MixedReality.ObjectAnchors.Conversion --version 0.3.0-beta.4
ProductVersions
.NET Standard
netstandard2.0

README

Azure Object Anchors client library for .NET

Azure Object Anchors enables an application to detect an object in the physical world using a 3D model and estimate its 6-DoF pose. This package supports the conversion of an existing 3D asset into a form that can be used by the Object Anchors runtime to detect physical objects.

Source code | Package (NuGet)

Getting started

Install the package

Install the Azure Object Anchors client library for .NET with NuGet:

dotnet add package Azure.MixedReality.ObjectAnchors.Conversion --prerelease

Add a package reference:

<PackageReference Include="Azure.MixedReality.ObjectAnchors.Conversion" Version="0.1.0-beta.0" />

Prerequisites

Authenticate the client

Mixed Reality services support a few different forms of authentication:

  • Account Key authentication
    • Account keys enable you to get started quickly with using Mixed Reality services. But before you deploy your application to production, we recommend that you update your app to use Azure AD authentication.
  • Azure Active Directory (AD) token authentication
    • If you're building an enterprise application and your company is using Azure AD as its identity system, you can use user-based Azure AD authentication in your app. You then grant access to your Object Anchors account by using your existing Azure AD security groups. You can also grant access directly to users in your organization.
    • Otherwise, we recommend that you obtain Azure AD tokens from a web service that supports your app. We recommend this method for production applications because it allows you to avoid embedding the credentials for access to the Object Anchors asset conversion service in your client application.

See here for detailed instructions and information.

Key concepts

ObjectAnchorsConversionClient

The ObjectAnchorsConversionClient is the client library used to access the Object Anchors asset conversion service. From there, a storage upload URI will be provided for users to upload their assets for conversion into a format that is usable by the Object Anchors runtime.

Assets uploaded to the Microsoft-hosted URI obtained from the client will be retained for 48 hours.

The final converted model in Microsoft-hosted storage will be retained for 48 hours.

Examples

Upload an asset for Object Anchors asset conversion

AzureKeyCredential credential = new AzureKeyCredential(accountKey);

ObjectAnchorsConversionClient client = new ObjectAnchorsConversionClient(accountId, accountDomain, credential);

AssetUploadUriResult uploadUriResult = await client.GetAssetUploadUriAsync();

Uri uploadedInputAssetUri = uploadUriResult.UploadUri;

BlobClient blobClient = new BlobClient(uploadedInputAssetUri);

using (FileStream fs = File.OpenRead(localFilePath))
{
  await blobClient.UploadAsync(fs);
}

Start 3D asset conversion

AssetConversionOptions assetConversionOptions = new AssetConversionOptions(uploadedInputAssetUri, AssetFileType.FromFilePath(localFilePath), assetGravity, scale);

AssetConversionOperation operation = await client.StartAssetConversionAsync(assetConversionOptions);

Guid jobId = new Guid(operation.Id);

Poll an existing ObjectAnchors asset conversion until completion and download the result

AssetConversionOperation operation = new AssetConversionOperation(assetConversionJobId, client);

await operation.WaitForCompletionAsync();

if (!operation.HasCompletedSuccessfully)
{
  throw new Exception("The asset conversion operation completed with an unsuccessful status");
}

BlobClient blobClient = new BlobClient(operation.Value.OutputModelUri);

BlobDownloadInfo downloadInfo = await blobClient.DownloadAsync();

using (FileStream file = File.OpenWrite(localFileDownloadPath))
{
    await downloadInfo.Content.CopyToAsync(file);
    FileInfo fileInfo = new FileInfo(localFileDownloadPath);
}

Troubleshooting

Next steps

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Changes from Previous Version

No structural changes between v0.3.0-beta.3 and v0.3.0-beta.4.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.NuGet marks this package as deprecated. Review the publisher's migration guidance before adopting it.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.