Object-detection consumer
ObjectDetectionConsumer subscribes to the AR 51 object-detection stream and spawns/updates Unity GameObjects for detected markers (simple 3-DoF points) and 6-DoF objects. It's a singleton component — access it via ObjectDetectionConsumer.Instance. Positions are Unity world-space, in meters.
Setup
Add an ObjectDetectionConsumer to your scene and configure it in the Inspector:
Prefabs— pool for 6-DoF objects, matched by name to the server object'sName.MarkerItems— per-marker-type prefab overrides (MarkerType→Prefab).- Visibility:
ShowMarkers,ShowObjects,ShowSkeletonMarkers,ShowMarkerItems. - Sizing:
MarkerSize(global multiplier),SkeletonMarkerSize,BasketballRadius. - Smoothing (optional):
EnabledFiltering(Kalman) withProcessNoise/MeasurementNoise, plusSmoothPositionalFactor,SmoothPositionalThreshold(meters),SmoothRotationFactor,SmoothRotationAngleThreshold(degrees).
Reading detections
Subscribe to each frame, or read the current set any time:
using AR51.Unity.SDK;
var consumer = ObjectDetectionConsumer.Instance;
consumer.OnObjectDetectionReceived += (s, reply) => {
// fires once per detection frame, before GameObjects are updated
};
foreach (var inst in consumer.TrackedObjects) // 6-DoF objects (also: TrackedMarkers, TrackedInstances)
{
string id = inst.Id; // server object id
Vector3 pos = inst.Position; // world space, meters
Color color = inst.Color;
}
TrackedInstance (a component on each spawned GameObject) is the per-object data model:
| Member | Meaning |
|---|---|
Id | server marker/object id |
Type | InstanceType.Marker or .Object |
ColorName / Color | server type/color label, and resolved Unity color |
Position | current world position (meters) |
Radius | marker radius ⚠️ (units appear to be meters / a scale × MarkerSize) |
CaptureTime | server capture timestamp (seconds) |
IsSkeletonMarker | true for skeleton-joint markers |
Registering a trackable object
Define a new rigid object from a set of marker instances (their color types + positions, recentered to their average):
consumer.AddTrackedObject("my-prop", markerInstances); // TrackedInstance[]
consumer.RemoveTrackedObject("my-prop");
consumer.ResetModels(); // destroy all spawned markers/objects and clear tracking
(For the operator-side, point-and-click workflow, see Mocap Studio → Registering tracked objects.)
Generic object transforms
For objects whose pose is streamed directly (position/rotation/scale) rather than detected from markers, ObjectTransformConsumer maintains matching prefab GameObjects — feed it ObjectTransform records (Id, Type, Position, Rotation, Scale). XR headset poses arrive this way as type "XR".