title | description | author | manager | services | ms.author | ms.date | ms.topic | ms.service |
---|---|---|---|---|---|---|---|---|
Coarse relocalization in C++/NDK |
In-depth explanation of how to create and locate anchors using coarse relocalization in C++/NDK. |
pamistel |
MehranAzimi-msft |
azure-spatial-anchors |
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 on C++ and the Android Native Development Kit.
- 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
std::shared_ptr<PlatformLocationProvider> sensorProvider;
sensorProvider = std::make_shared<PlatformLocationProvider>();
// Allow GPS
const std::shared_ptr<SensorCapabilities>& sensors = sensorProvider->Sensors();
sensors->GeoLocationEnabled(true);
// Allow WiFi scanning
sensors->WifiEnabled(true);
// Populate the set of known BLE beacons' UUIDs
std::vector<std::string> uuids;
uuids.push_back("22e38f1a-c1b3-452b-b5ce-fdb0f39535c1");
uuids.push_back("a63819b9-8b7b-436d-88ec-ea5d8db2acb0");
// Allow the set of known BLE beacons
sensors->BluetoothEnabled(true);
sensors->KnownBeaconProximityUuids(uuids);
[!INCLUDE Configure Provider]
// Set the session's sensor fingerprint provider
cloudSpatialAnchorSession->LocationProvider(sensorProvider);
// Configure the near-device criteria
auto nearDeviceCriteria = std::make_shared<NearDeviceCriteria>();
nearDeviceCriteria->DistanceInMeters(5.0f);
nearDeviceCriteria->MaxResultCount(25);
// Set the session's locate criteria
auto anchorLocateCriteria = std::make_shared<AnchorLocateCriteria>();
anchorLocateCriteria->NearDevice(nearDeviceCriteria);
cloudSpatialAnchorSession->CreateWatcher(anchorLocateCriteria);
[!INCLUDE Locate]
[!INCLUDE Configure Provider]