Skip to content

Commit a6664c0

Browse files
authored
Merge pull request #194067 from dfields-msft/user/dfields/ObjectAnchorsSnippets
Correct a few minor issues in AOA code snippets
2 parents eb8cf76 + 64d3e36 commit a6664c0

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

articles/object-anchors/concepts/sdk-overview.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ ObjectModel model = await observer.LoadObjectModelAsync(modelAsBytes);
178178
The application creates a query to detect instances of that model within a space.
179179

180180
```cs
181+
#if WINDOWS_UWP || DOTNETWINRT_PRESENT
182+
#define SPATIALCOORDINATESYSTEM_API_PRESENT
183+
#endif
184+
181185
using Microsoft.Azure.ObjectAnchors;
182186
using Microsoft.Azure.ObjectAnchors.SpatialGraph;
183187
using Microsoft.Azure.ObjectAnchors.Unity;
@@ -186,7 +190,7 @@ using UnityEngine;
186190
// Get the coordinate system.
187191
SpatialGraphCoordinateSystem? coordinateSystem = null;
188192

189-
#if WINDOWS_UWP
193+
#if SPATIALCOORDINATESYSTEM_API_PRESENT
190194
SpatialCoordinateSystem worldOrigin = ObjectAnchorsWorldManager.WorldOrigin;
191195
if (worldOrigin != null)
192196
{
@@ -237,7 +241,7 @@ foreach (ObjectInstance instance in detectedObjects)
237241
// Supported modes:
238242
// "LowLatencyCoarsePosition" - Consumes less CPU cycles thus fast to
239243
// update the state.
240-
// "HighLatencyAccuratePosition" - (Not yet implemented) Consumes more CPU
244+
// "HighLatencyAccuratePosition" - Uses the device's camera and consumes more CPU
241245
// cycles thus potentially taking longer
242246
// time to update the state.
243247
// "Paused" - Stops to update the state until mode
@@ -257,25 +261,24 @@ In the state changed event, we can query the latest state or dispose an instance
257261
```cs
258262
using Microsoft.Azure.ObjectAnchors;
259263

260-
var InstanceChangedHandler = new Windows.Foundation.TypedEventHandler<ObjectInstance, ObjectInstanceChangedEventArgs>((sender, args) =>
264+
void InstanceChangedHandler(object sender, ObjectInstanceChangedEventArgs args)
261265
{
262266
// Try to query the current instance state.
263-
ObjectInstanceState? state = sender.TryGetCurrentState();
267+
ObjectInstanceState state = sender.TryGetCurrentState();
264268

265-
if (state.HasValue)
269+
if (state != null)
266270
{
267-
// Process latest state via state.Value.
268-
// An object pose includes scale, rotation and translation, applied in
271+
// Process latest state.
272+
// An object pose includes rotation and translation, applied in
269273
// the same order to the object model in the centered coordinate system.
270274
}
271275
else
272276
{
273277
// This object instance is lost for tracking, and will never be recovered.
274278
// The caller can detach the Changed event handler from this instance
275279
// and dispose it.
276-
sender.Dispose();
277280
}
278-
});
281+
}
279282
```
280283

281284
Also, an application can optionally record one or multiple diagnostics sessions for offline debugging.

0 commit comments

Comments
 (0)