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

Prefix Reserved
This is a prerelease version of Azure.MixedReality.ObjectAnchors.Conversion.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Azure.MixedReality.ObjectAnchors.Conversion --version 0.3.0-beta.2                
NuGet\Install-Package Azure.MixedReality.ObjectAnchors.Conversion -Version 0.3.0-beta.2                
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.
<PackageReference Include="Azure.MixedReality.ObjectAnchors.Conversion" Version="0.3.0-beta.2" />                
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.2                
#r "nuget: Azure.MixedReality.ObjectAnchors.Conversion, 0.3.0-beta.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. 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.2&prerelease

// Install Azure.MixedReality.ObjectAnchors.Conversion as a Cake Tool
#tool nuget:?package=Azure.MixedReality.ObjectAnchors.Conversion&version=0.3.0-beta.2&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 using one of the following methods.

From Visual Studio Package Manager:

Install-Package Azure.MixedReality.ObjectAnchors.Conversion

From .NET CLI

dotnet add package Azure.MixedReality.ObjectAnchors.Conversion

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 Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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.6 2,589 11/3/2022
0.3.0-beta.5 738 9/13/2022
0.3.0-beta.4 313 7/29/2022
0.3.0-beta.3 431 5/11/2022
0.3.0-beta.2 420 3/8/2022
0.3.0-beta.1 754 7/14/2021
0.2.0-beta.1 567 5/11/2021
0.1.0-beta.1 500 2/26/2021