Spatial.AprilTagDictionary
static AprilTagDict AprilTagDictionary{ get set }
Description
Which family of AprilTag markers
SpatialCapability.AprilTag looks for. Markers from other
dictionaries aren’t detected, so this must match the markers you
printed! Default lets StereoKit pick. Changing it while AprilTags
are being tracked restarts that tracking.
Examples
Finding an ArUco marker by id
The dictionary must match the markers you printed, or they won’t be
detected. AprilTags work the same way, via AprilTagDictionary.
public void StartAruco()
{
Spatial.ArucoDictionary = ArucoDict.Dict4x4_50;
// A 10cm printed marker, used by runtimes that support known sizes
Spatial.SetMarkerSize(MarkerType.Aruco, 0.1f);
// Markers taped to a wall can have their pose refined over time
Spatial.SetMarkerStationary(MarkerType.Aruco, true);
Spatial.Request(SpatialCapability.Aruco);
}
static bool FindMarker(uint id, out Pose pose)
{
foreach (SpatialEntity marker in SpatialEntity.With(SpatialComponent.Marker))
{
if (marker.TryGetMarker(out MarkerType type, out uint markerId) && type == MarkerType.Aruco && markerId == id)
return marker.TryGetBounds2D(out pose, out _);
}
pose = Pose.Identity;
return false;
}
Found an issue with these docs, or have some additional questions? Create an Issue on Github!