Spatial.SetMarkerSize
static void SetMarkerSize(MarkerType type, float sizeMeters)
Tell the system how big your printed markers of this
type are. This matters most for ArUco and AprilTags, where a
known size can help a runtime judge marker distance, but it’s
only a hint, and runtimes may ignore it. Changing this while that
marker type is being tracked restarts its tracking, so set it
before Request when you can.
| MarkerType type | The marker type this size applies to. |
| float sizeMeters | The edge length of the marker’s square, in meters. Use 0 if the sizes are mixed or unknown. |
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!