CloudSpatialAnchorSession Class

  • java.lang.Object
    • java.lang.AutoCloseable
      • com.microsoft.azure.spatialanchors.CloudSpatialAnchorSession

public class CloudSpatialAnchorSession

Use this class to create, locate and manage spatial anchors.

Constructor Summary

Constructor Description
CloudSpatialAnchorSession()

Initializes a new instance with a default configuration.

Method Summary

Modifier and Type Method and Description
void addAnchorLocatedListener(AnchorLocatedListener listener)

Adds the specified listener to receive AnchorLocated events. Occurs when an anchor's location is determined.

void addErrorListener(SessionErrorListener listener)

Adds the specified listener to receive Error events. Occurs when the session is unable to continue processing.

void addLocateAnchorsCompletedListener(LocateAnchorsCompletedListener listener)

Adds the specified listener to receive LocateAnchorsCompleted events. Occurs when all the results from a watcher that is locating anchors are processed.

void addOnLogDebugListener(OnLogDebugListener listener)

Adds the specified listener to receive OnLogDebug events. Occurs when a debug log message is generated.

void addSessionUpdatedListener(SessionUpdatedListener listener)

Adds the specified listener to receive SessionUpdated events. Occurs when all the session state is updated.

void addTokenRequiredListener(TokenRequiredListener listener)

Adds the specified listener to receive TokenRequired events. Occurs when the session requires an updated access token or authentication token.

void addUpdatedSensorFingerprintRequiredListener(UpdatedSensorFingerprintRequiredListener listener)

Adds the specified listener to receive UpdatedSensorFingerprintRequired events. Occurs when the session requests an updated sensor fingerprint from the application.

void close()

Closes this resource.

Future createAnchorAsync(final CloudSpatialAnchor anchor)

Creates a new persisted spatial anchor from the specified local anchor and string properties. The local anchor passed into this method must have a valid transform. Note some platforms supported by Azure Spatial Anchors such as iOS allow transforms with scale component != 1.0. Azure Spatial Anchors SDK does not support such transforms and it will fail to create the spatial anchor with error code InvalidAnchorTransformRigidity. Any scale handling for anchors must be done at the app level.

CloudSpatialAnchorWatcher createWatcher(AnchorLocateCriteria criteria)

Creates a new object that watches for anchors that meet the specified criteria.

Future deleteAnchorAsync(final CloudSpatialAnchor anchor)

Deletes a persisted spatial anchor.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

Future<String> getAccessTokenWithAccountKeyAsync(final String accountKey)

Gets the Azure Spatial Anchors access token from account key.

Future<String> getAccessTokenWithAuthenticationTokenAsync(final String authenticationToken)

Gets the Azure Spatial Anchors access token from authentication token.

List<CloudSpatialAnchorWatcher> getActiveWatchers()

Gets a list of active watchers.

Future<CloudSpatialAnchor> getAnchorPropertiesAsync(final String identifier)

Gets a cloud spatial anchor for the given identifier, even if it hasn't been located yet.

SessionConfiguration getConfiguration()

Gets the configuration information for the session. Configuration settings take effect when the session is started.

CloudSpatialAnchorSessionDiagnostics getDiagnostics()

Gets the diagnostics settings for the session, which can be used to collect and submit data for troubleshooting and improvements.

PlatformLocationProvider getLocationProvider()

Location provider used to create and locate anchors using [Coarse Relocalization](https://aka.ms/CoarseRelocalization).

SessionLogLevel getLogLevel()

Logging level for the session log events.

Future<List<String>> getNearbyAnchorIdsAsync(final NearDeviceCriteria criteria)

Gets a list of all nearby cloud spatial anchor ids corresponding to a given criteria.

Session getSession()

Gets the tracking session used to help locate anchors. This property is not available on the HoloLens platform.

String getSessionId()

Gets the unique identifier for the session.

Future<SessionStatus> getSessionStatusAsync()

Gets an object describing the status of the session.

boolean getTelemetryEnabled()
void processFrame(Frame frame)

Applications must call this method on platforms where per-frame processing is required. This method is not available on the HoloLens platform.

Future refreshAnchorPropertiesAsync(final CloudSpatialAnchor anchor)

Refreshes properties for the specified spatial anchor.

void removeAnchorLocatedListener(AnchorLocatedListener listener)

Removes the specified listener to receive AnchorLocated events. Occurs when an anchor's location is determined.

void removeErrorListener(SessionErrorListener listener)

Removes the specified listener to receive Error events. Occurs when the session is unable to continue processing.

void removeLocateAnchorsCompletedListener(LocateAnchorsCompletedListener listener)

Removes the specified listener to receive LocateAnchorsCompleted events. Occurs when all the results from a watcher that is locating anchors are processed.

void removeOnLogDebugListener(OnLogDebugListener listener)

Removes the specified listener to receive OnLogDebug events. Occurs when a debug log message is generated.

void removeSessionUpdatedListener(SessionUpdatedListener listener)

Removes the specified listener to receive SessionUpdated events. Occurs when all the session state is updated.

void removeTokenRequiredListener(TokenRequiredListener listener)

Removes the specified listener to receive TokenRequired events. Occurs when the session requires an updated access token or authentication token.

void removeUpdatedSensorFingerprintRequiredListener(UpdatedSensorFingerprintRequiredListener listener)

Removes the specified listener to receive UpdatedSensorFingerprintRequired events. Occurs when the session requests an updated sensor fingerprint from the application.

void reset()

Resets environment data that has been captured in this session; applications must call this method when tracking is lost. On any platform, calling the method will clean all internal cached state.

void setLocationProvider(PlatformLocationProvider value)

Location provider used to create and locate anchors using [Coarse Relocalization](https://aka.ms/CoarseRelocalization).

void setLogLevel(SessionLogLevel value)

Logging level for the session log events.

void setSession(Session value)

Sets the tracking session used to help locate anchors. This property is not available on the HoloLens platform.

void setTelemetryEnabled(boolean value)
void start()

Begins capturing environment data for the session.

void stop()

Stops capturing environment data for the session and cancels any outstanding locate operations. Environment data is maintained.

Future updateAnchorPropertiesAsync(final CloudSpatialAnchor anchor)

Updates the specified spatial anchor.

Constructor Details

CloudSpatialAnchorSession

public CloudSpatialAnchorSession()

Initializes a new instance with a default configuration.

Method Details

addAnchorLocatedListener

public void addAnchorLocatedListener(AnchorLocatedListener listener)

Adds the specified listener to receive AnchorLocated events. Occurs when an anchor's location is determined.

Parameters:

listener

addErrorListener

public void addErrorListener(SessionErrorListener listener)

Adds the specified listener to receive Error events. Occurs when the session is unable to continue processing.

Parameters:

listener

addLocateAnchorsCompletedListener

public void addLocateAnchorsCompletedListener(LocateAnchorsCompletedListener listener)

Adds the specified listener to receive LocateAnchorsCompleted events. Occurs when all the results from a watcher that is locating anchors are processed.

Parameters:

listener

addOnLogDebugListener

public void addOnLogDebugListener(OnLogDebugListener listener)

Adds the specified listener to receive OnLogDebug events. Occurs when a debug log message is generated.

Parameters:

listener

addSessionUpdatedListener

public void addSessionUpdatedListener(SessionUpdatedListener listener)

Adds the specified listener to receive SessionUpdated events. Occurs when all the session state is updated.

Parameters:

listener

addTokenRequiredListener

public void addTokenRequiredListener(TokenRequiredListener listener)

Adds the specified listener to receive TokenRequired events. Occurs when the session requires an updated access token or authentication token.

Parameters:

listener

addUpdatedSensorFingerprintRequiredListener

public void addUpdatedSensorFingerprintRequiredListener(UpdatedSensorFingerprintRequiredListener listener)

Adds the specified listener to receive UpdatedSensorFingerprintRequired events. Occurs when the session requests an updated sensor fingerprint from the application.

Parameters:

listener

close

public void close()

Closes this resource.

createAnchorAsync

public Future createAnchorAsync(final CloudSpatialAnchor anchor)

Creates a new persisted spatial anchor from the specified local anchor and string properties. The local anchor passed into this method must have a valid transform. Note some platforms supported by Azure Spatial Anchors such as iOS allow transforms with scale component != 1.0. Azure Spatial Anchors SDK does not support such transforms and it will fail to create the spatial anchor with error code InvalidAnchorTransformRigidity. Any scale handling for anchors must be done at the app level.

Parameters:

anchor - Anchor to be persisted.

createWatcher

public CloudSpatialAnchorWatcher createWatcher(AnchorLocateCriteria criteria)

Creates a new object that watches for anchors that meet the specified criteria.

Parameters:

criteria - Criteria for anchors to watch for.

deleteAnchorAsync

public Future deleteAnchorAsync(final CloudSpatialAnchor anchor)

Deletes a persisted spatial anchor.

Parameters:

anchor - The anchor to be deleted.

finalize

protected void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

getAccessTokenWithAccountKeyAsync

public Future getAccessTokenWithAccountKeyAsync(final String accountKey)

Gets the Azure Spatial Anchors access token from account key.

Parameters:

accountKey - Account key.

getAccessTokenWithAuthenticationTokenAsync

public Future getAccessTokenWithAuthenticationTokenAsync(final String authenticationToken)

Gets the Azure Spatial Anchors access token from authentication token.

Parameters:

authenticationToken - Authentication token.

getActiveWatchers

public List getActiveWatchers()

Gets a list of active watchers.

getAnchorPropertiesAsync

public Future getAnchorPropertiesAsync(final String identifier)

Gets a cloud spatial anchor for the given identifier, even if it hasn't been located yet.

Parameters:

identifier - The identifier to look for.

getConfiguration

public SessionConfiguration getConfiguration()

Gets the configuration information for the session. Configuration settings take effect when the session is started.

getDiagnostics

public CloudSpatialAnchorSessionDiagnostics getDiagnostics()

Gets the diagnostics settings for the session, which can be used to collect and submit data for troubleshooting and improvements.

getLocationProvider

public PlatformLocationProvider getLocationProvider()

Location provider used to create and locate anchors using [Coarse Relocalization](https://aka.ms/CoarseRelocalization).

getLogLevel

public SessionLogLevel getLogLevel()

Logging level for the session log events.

getNearbyAnchorIdsAsync

public Future<>> getNearbyAnchorIdsAsync(final NearDeviceCriteria criteria)

Gets a list of all nearby cloud spatial anchor ids corresponding to a given criteria.

Parameters:

criteria - The search criteria.

getSession

public Session getSession()

Gets the tracking session used to help locate anchors. This property is not available on the HoloLens platform.

getSessionId

public String getSessionId()

Gets the unique identifier for the session.

getSessionStatusAsync

public Future getSessionStatusAsync()

Gets an object describing the status of the session.

getTelemetryEnabled

public boolean getTelemetryEnabled()

processFrame

public void processFrame(Frame frame)

Applications must call this method on platforms where per-frame processing is required. This method is not available on the HoloLens platform.

Parameters:

frame - AR frame to process.

refreshAnchorPropertiesAsync

public Future refreshAnchorPropertiesAsync(final CloudSpatialAnchor anchor)

Refreshes properties for the specified spatial anchor.

Parameters:

anchor - The anchor to refresh.

removeAnchorLocatedListener

public void removeAnchorLocatedListener(AnchorLocatedListener listener)

Removes the specified listener to receive AnchorLocated events. Occurs when an anchor's location is determined.

Parameters:

listener

removeErrorListener

public void removeErrorListener(SessionErrorListener listener)

Removes the specified listener to receive Error events. Occurs when the session is unable to continue processing.

Parameters:

listener

removeLocateAnchorsCompletedListener

public void removeLocateAnchorsCompletedListener(LocateAnchorsCompletedListener listener)

Removes the specified listener to receive LocateAnchorsCompleted events. Occurs when all the results from a watcher that is locating anchors are processed.

Parameters:

listener

removeOnLogDebugListener

public void removeOnLogDebugListener(OnLogDebugListener listener)

Removes the specified listener to receive OnLogDebug events. Occurs when a debug log message is generated.

Parameters:

listener

removeSessionUpdatedListener

public void removeSessionUpdatedListener(SessionUpdatedListener listener)

Removes the specified listener to receive SessionUpdated events. Occurs when all the session state is updated.

Parameters:

listener

removeTokenRequiredListener

public void removeTokenRequiredListener(TokenRequiredListener listener)

Removes the specified listener to receive TokenRequired events. Occurs when the session requires an updated access token or authentication token.

Parameters:

listener

removeUpdatedSensorFingerprintRequiredListener

public void removeUpdatedSensorFingerprintRequiredListener(UpdatedSensorFingerprintRequiredListener listener)

Removes the specified listener to receive UpdatedSensorFingerprintRequired events. Occurs when the session requests an updated sensor fingerprint from the application.

Parameters:

listener

reset

public void reset()

Resets environment data that has been captured in this session; applications must call this method when tracking is lost. On any platform, calling the method will clean all internal cached state.

setLocationProvider

public void setLocationProvider(PlatformLocationProvider value)

Location provider used to create and locate anchors using [Coarse Relocalization](https://aka.ms/CoarseRelocalization).

Parameters:

value - The new value.

setLogLevel

public void setLogLevel(SessionLogLevel value)

Logging level for the session log events.

Parameters:

value - The new value.

setSession

public void setSession(Session value)

Sets the tracking session used to help locate anchors. This property is not available on the HoloLens platform.

Parameters:

value - The new value.

setTelemetryEnabled

public void setTelemetryEnabled(boolean value)

Parameters:

value

start

public void start()

Begins capturing environment data for the session.

stop

public void stop()

Stops capturing environment data for the session and cancels any outstanding locate operations. Environment data is maintained.

updateAnchorPropertiesAsync

public Future updateAnchorPropertiesAsync(final CloudSpatialAnchor anchor)

Updates the specified spatial anchor.

Parameters:

anchor - The anchor to be updated.

Applies to