title | description | author | manager | services | ms.custom | ms.author | ms.date | ms.topic | ms.service |
---|---|---|---|---|---|---|---|---|---|
Coarse relocalization in Java |
In-depth explanation of how to create and locate anchors using coarse relocalization in Java. |
pamistel |
MehranAzimi-msft |
azure-spatial-anchors |
devx-track-java, devx-track-extended-java |
pamistel |
11/20/2020 |
tutorial |
azure-spatial-anchors |
[!div class="op_single_selector"]
Azure Spatial Anchors can associate on-device, positioning sensor data with the anchors you create. This data can also be used to quickly determine whether there are any anchors nearby your device. For more information, see Coarse relocalization.
To complete this guide, make sure you have:
- Basic knowledge of Java.
- Read through the Azure Spatial Anchors overview.
- Completed one of the 5-minute Quickstarts.
- Read through the Create and locate anchors how-to.
[!INCLUDE Configure Provider]
// Create the sensor fingerprint provider
PlatformLocationProvider sensorProvider = new PlatformLocationProvider();
// Allow GPS
SensorCapabilities sensors = sensorProvider.getSensors();
sensors.setGeoLocationEnabled(true);
// Allow WiFi scanning
sensors.setWifiEnabled(true);
// Populate the set of known BLE beacons' UUIDs
String uuids[] = new String[2];
uuids[0] = "22e38f1a-c1b3-452b-b5ce-fdb0f39535c1";
uuids[1] = "a63819b9-8b7b-436d-88ec-ea5d8db2acb0";
// Allow the set of known BLE beacons
sensors.setBluetoothEnabled(true);
sensors.setKnownBeaconProximityUuids(uuids);
[!INCLUDE Configure Provider]
// Set the session's sensor fingerprint provider
cloudSpatialAnchorSession.setLocationProvider(sensorProvider);
// Configure the near-device criteria
NearDeviceCriteria nearDeviceCriteria = new NearDeviceCriteria();
nearDeviceCriteria.setDistanceInMeters(5.0f);
nearDeviceCriteria.setMaxResultCount(25);
// Set the session's locate criteria
AnchorLocateCriteria anchorLocateCriteria = new AnchorLocateCriteria();
anchorLocateCriteria.setNearDevice(nearDeviceCriteria);
cloudSpatialAnchorSession.createWatcher(anchorLocateCriteria);
[!INCLUDE Locate]
[!INCLUDE Configure Provider]