Azure.MixedReality.ObjectAnchors.Conversion 0.3.0-beta.5

.NET Standard 2.0
This is a prerelease version of Azure.MixedReality.ObjectAnchors.Conversion.
NuGet\Install-Package Azure.MixedReality.ObjectAnchors.Conversion -Version 0.3.0-beta.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package Azure.MixedReality.ObjectAnchors.Conversion --version 0.3.0-beta.5
<PackageReference Include="Azure.MixedReality.ObjectAnchors.Conversion" Version="0.3.0-beta.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Azure.MixedReality.ObjectAnchors.Conversion --version 0.3.0-beta.5
#r "nuget: Azure.MixedReality.ObjectAnchors.Conversion, 0.3.0-beta.5"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Azure.MixedReality.ObjectAnchors.Conversion as a Cake Addin
#addin nuget:?package=Azure.MixedReality.ObjectAnchors.Conversion&version=0.3.0-beta.5&prerelease

// Install Azure.MixedReality.ObjectAnchors.Conversion as a Cake Tool
#tool nuget:?package=Azure.MixedReality.ObjectAnchors.Conversion&version=0.3.0-beta.5&prerelease

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 opencode@microsoft.com with any additional questions or comments.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.0-beta.5 88 9/13/2022
0.3.0-beta.4 200 7/29/2022
0.3.0-beta.3 356 5/11/2022
0.3.0-beta.2 324 3/8/2022
0.3.0-beta.1 628 7/14/2021
0.2.0-beta.1 502 5/11/2021
0.1.0-beta.1 430 2/26/2021