SpatialEntity.TryGetMarker
bool TryGetMarker(MarkerType& type, UInt32& markerId)
Marker information, for entities discovered by a marker
tracking capability like QR codes or ArUco markers. The marker’s
pose and physical size come from TryGetBounds2D.
| MarkerType& type | What kind of marker this is. |
| UInt32& markerId | The marker’s numeric id, for marker dictionaries like ArUco and AprilTag. 0 for QR codes. |
| RETURNS: bool | False if this entity has no marker component. |
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!